Mit einem kleinen Lüfter (der von einer Solarzelle angetrieben wird), könntest du doch das Kondensatproblem lösen.
Aber mal ne andere Frage, wie genau erzeugst du den dieses schicke Diagramm ?
Mit einem kleinen Lüfter (der von einer Solarzelle angetrieben wird), könntest du doch das Kondensatproblem lösen.
Aber mal ne andere Frage, wie genau erzeugst du den dieses schicke Diagramm ?
Hallo,
hab nun das Problem vermutlich gefunden, allerdings noch keine Lösung.
Sobald der ENC28J60 den Stom nichtmehr vom Arduino bezieht funktioniert alles.
Sobald ich den Strom wieder vom Arduino beziehe, geht nichtsmehr.
Ich muss in meinem Fall also entweder den ENC28j60 extern mit Strom versorgen.
Viele Dank für eure Hilfe.
Geht das Den ?
Den an dem TX& RX PIN hängt doch der ATiny-Empfänger dran.
Hallo Zusammen,
ich möchte gern meinen RasperryPi durch einen Arduino mini Pro ersetzen.
An den Arduino ist noch ein Netzwerkchip ENJC28J60 angeschlossen.
Der Arduino soll die Daten per UART (TX&RX PIN) entgegennehmen und so wie sie sind per GET und URL an einen Server schicken.
Dazu habe ich einen Sketch geschrieben, siehe Ende vom Post.
Wenn ich den Arduino an den FDTI-Programmer anschließe und im Serial-Monitor meine Testzeichenfolge "10 v=3412&t=2550&h=6100 " eingebe,
dann schickt der Arduino eine GET-Anfrage an den Server "http://server/tempsensors/ad…2&t=2550&h=6100".
Alles Super. ![]()
Schließe ich den ATINY Empfänger aus der letzten Sammelbestellung mit den TX&RX-Pin an den FDTI-Programmer an und starte in der Arduino IDE den Serial-Monitor, dann werden mir die empfangenen Werte von meinen Sensoren angezeigt. also z.B.: "10 v=3412&t=2550&h=6100"
Die Überträgung Atiny zum Raspberry funktioniert übrigens auch super.
Damit gehe ich davon aus, das der ATINY-Empfänger funktioniert, und das der Arduino inkl Netzwerkanbindung und Sketch funktioniert.
Schließe ich jetzt aber den Arduino TX-Pin an den Atiny RX PIN und den Arduino RX and den Atiny TX pin, dann werden keinen Daten mehr an den Server übertragen.
Der Atiny blinkt aber noch 2mal wenn er Daten empfängt.
Sowohl Atiny als auch Arduino laufen selbst mit 8MHZ und die serielle Schnittstelle mit 9600 BAUD. Strom bekommen beide von einem Raspberry (dient nur als Stromquelle).
Hat jemand eine Idee, warum der Arduino keine Daten empfängt/weiterleitet wenn der Atiny angeschlossen ist ?
Sketch vom Arduino:
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
char inData[23];
char inChar=-1;
byte index = 0;
char URLstring[23];
// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
byte Ethernet::buffer[700];
static uint32_t timer;
const char website[] PROGMEM = "linux-q446.fritz.box";
// called when the client request is complete
static void my_callback (byte status, word off, word len) {
Serial.println(">>>");
Ethernet::buffer[off+300] = 0;
Serial.print((const char*) Ethernet::buffer + off);
Serial.println("...");
}
void setup () {
Serial.begin(9600);
Serial.println(F("\n[webClient]"));
if (ether.begin(sizeof Ethernet::buffer, mymac,10) == 0).
Serial.println(F("Failed to access Ethernet controller"));
if (!ether.dhcpSetup())
Serial.println(F("DHCP failed"));
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);..
ether.printIp("DNS: ", ether.dnsip);..
if (!ether.dnsLookup(website))
Serial.println("DNS failed");
ether.printIp("SRV: ", ether.hisip);
}
void loop ().
{
ether.packetLoop(ether.packetReceive());
while(Serial.available())
{
inChar = Serial.read();
delay(10);
inData[index] = inChar;
index++;
inData[index] = '\0';
};
if (index > 0) mächt nur etwas, wenn Daten komplett empfangen wurden {//
strcpy(URLstring,"");//leer den String
strcat(URLstring,inData);//hängt den Inhalt von inData an
URLstring[2]='&';//ersetzt das leerzeichen, wass immer an der 3. stelle ist mit einem &
ether.browseUrl(PSTR("/tempsensors/add.php?node="),URLstring, website, my_callback); //schickt die Daten an den Webserver
index=0;
};
}
Display More
Hallo, muss ich beim TinyTX aus der letzten Sammelbestellung beim Anschluss eines DHT22 noch einen Widerstand einbauen? Und wenn ja, von welchem Pin zu welchem Pin ?
Hallo,
mal ein Frage.
die Aktuelle Index-php zum Darstellen der Messwerte ist ja leider nicht mit MySQL kompatibel.
Was ist den aus dem Webinterface für die Darstellung der Daten der TinySensor.py geworden ?
Display More"Zitat von Damals"
So, noch ein paar kleinere Änderungen- Unterstützung für MySQL eingebaut, für den Fall das jemand zB. mehrere RaspberryPI's hat aber alle in eine Datenbank schreiben sollen, oder einfach nur um die Daten auszulagern.
Dafür verwende ich CyMySQL da das einfacher einzubauen ist (für MySQLdb mit python3 ist der Installationsaufwand größer).Aber ich muss euch dennoch warnen, MySQL ist (zumindest auf dem Pi-1) langsamer und verursacht auch mehr CPU+RAM Auslastung! Außerdem verballert es permanent CPU+RAM auch wenn es gar nicht genutzt wird.
Es wird wie mit SQLite pro NodeID eine Datenbank angelegt die aber mit dem Prefix TinyTX_ benannt ist (also zB. TinyTX_22) und in dieser Datenbank auch pro SensorType eine Tabelle.
- Serial ist etwas umfangreicher implementiert um genauere Einstellungen vornehmen zu können.
- Konsolen Ausgaben sind jetzt in Farbe
Also insbesondere der Hinweis das die Battery leer sein könnte, aber auch Fehlermeldungen. Später könnte man auch die SensorTypen Ausgaben einfärben aber ich will's ja nicht gleich übertreiben...
Zur Verwaltung der SQLite Datenbanken empfehle ich phpLiteAdmin, das ist nur ein PHP File was man irgendwo in /var/www/ ablegen brauch und ist so ähnlich wie phpMyAdmin.
"TinySensor.py"
[code=php]
#!/usr/bin/python3
# coding: utf-8
#
# Receive Data from TinyRX over UART and save directly to Datanbase.
# - SQLite and MySQL Support.
# - Creating for each Node an own Database and for each SensorType an own Table.
#
# v0.31 by meigrafd @ 08.02.2015
#
### Setup:
# You must install following packages:
# apt-get install python3 python3-serial
#
# Do following steps if you want to use MySQL instead of SQLite:
# apt-get install python3-pip
# pip3 install cymysql
#
#------------------------------------------------------------------------
# Specify your serial port path (/dev/ttyAMA0 is default for RaspberryPi)
SerialPort = '/dev/ttyAMA0'
# And its Speed
SerialBaudrate = 9600# Use SQLite or MySQL? [mysql / sqlite]
dbServ = 'sqlite'# Specify the directory for SQLite Database files
DBdir = '/var/Sensors'# If using MySQL specify Host, Port, Login and Password
mysqlHost = '127.0.0.1'
mysqlPort = '3306'
mysqlLogin = 'root'
mysqlPass = 'raspberry'# Specify the known types from sensors
# e.g.: ["v=Voltage=1000", "t=Temperature=100", "h=Humidity=100", "r=ReedSwitch", "p=Pressure", "us=Distance"]
# -> v must be in Datastring and volt is the name of Database-Table
# Not known types goes to Database Table -> unknown
# The second setting after Voltage (=1000) is the optional divide value eg. Voltage needs to get divide by 1000.
SensorTypes = ["v=Voltage=1000", "t=Temperature=100", "h=Humidity=100", "r=ReedSwitch", "p=Pressure", "us=Distance"]# Specify the battery limit in milliVolt for notice
batteryLimit = 3100# Enable TEST-MODE?
# If set to True the Script process's static lines and quits without adding or receiving anything.. (debugging)
testMode = False#------------------------------------------------------------------------
import time, os
try:
import serial
except ImportError:
print("ERROR: You must install serial Module: apt-get install python3-serial")
exit()
if dbServ == 'sqlite':
import sqlite3 as sqlite
elif dbServ == 'mysql':
try:
import cymysql
except ImportError:
print("ERROR: You must install cymysql Module: apt-get install python3-pip && pip3 install cymysql")
exit()
else:
print("ERROR: invalid 'dbServ' setting!")
exit()# serial docu: http://pyserial.sourceforge.net/pyserial.html
# initialization and open the port.
# possible timeout values:
# 1. None: wait forever, block call
# 2. 0: non-blocking mode, return immediately
# 3. x, x is bigger than 0, float allowed, timeout block call
ser = serial.Serial()
ser.port = SerialPort
ser.baudrate = SerialBaudrate
ser.bytesize = serial.EIGHTBITS #number of bits per bytes
ser.parity = serial.PARITY_NONE #set parity check: no parity
ser.stopbits = serial.STOPBITS_ONE #number of stop bits
#ser.timeout = None #block read
ser.timeout = 1 #non-block read
#ser.timeout = 2 #timeout block read
ser.xonxoff = False #disable software flow control
ser.rtscts = False #disable hardware (RTS/CTS) flow control
ser.dsrdtr = False #disable hardware (DSR/DTR) flow control
ser.writeTimeout = 2 #timeout for write
#------------------------------------------------------------------------# This handles console colors used for print's
#http://misc.flogisoft.com/bash/tip_colors_and_formatting
class c:
ENDC='\33[0m'
DEFAULT='\33[39m'; BOLD='\33[1m'; DIM='\33[2m'
RESBOLD='\33[21m'; RESDIM='\33[22m'
RED='\33[31m'; GREEN='\33[32m'; YELLOW='\33[33m'; CYAN='\33[36m'# This function process data from serial port and prints received values in human readable format
def processData(rx):
# rx: 22 v=3100&t=3400&h=6700&r=0
data = rx.strip().split(' ')
nodeID = data[0]
output = "NID:%s" % nodeID
#analyse data: v=3100&t=3400&h=6700&r=0
sensorData = data[1].split('&')
for senD in sensorData: #sensorData eg: v=3100 t=3400 h=6700 r=0
dbTable = "unknown"
divide = False
value = senD.split('=') #value eg: v 3100
for sType in SensorTypes: #sType eg: v=Voltage=1000
ssType = sType.split('=') #eg: v Voltage 1000
if value[0] == ssType[0]:
dbTable = ssType[1]
if len(ssType) > 2:
divide = ssType[2]
break
if divide:
VALUE = round(float(value[1]) / float(divide), 2)
if value[0] == "v":
if int(value[1]) < batteryLimit:
print(c.BOLD+c.RED+"Battery in your TinyTX id "+c.CYAN+nodeID+c.RED+" is running low!"+c.ENDC, end='')
print(" Actual reading shows: "+c.BOLD+c.YELLOW+str(value[1])+"mV"+c.ENDC)
output += " VCC:%sv" % VALUE
continue
else:
VALUE = value[1]
output += " "+dbTable+":%s" % VALUE
#insert into Database
if not testMode:
insertData(int(nodeID), dbTable, VALUE)
# Ausgabe
print(output)# This function inserts received data into sqlite database
def insertData(nodeID, table, data):
try:
con = None
if dbServ == 'mysql':
try:
con = cymysql.connect(host=mysqlHost, port=int(mysqlPort), user=mysqlLogin, passwd=mysqlPass)
cur = con.cursor()
cur.execute("CREATE DATABASE IF NOT EXISTS TinyTX_%s;", (nodeID))
cur.execute("USE TinyTX_%s;", (nodeID))
con.commit()
cur.execute("CREATE TABLE IF NOT EXISTS "+table+" (id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,time INT(11),value VARCHAR(20));")
cur.execute("INSERT INTO "+table+" (time, value) VALUES (%s,%s);", (timestamp, data))
except Exception as err:
print(c.BOLD+c.RED+"MySQL Error: "+str(err)+c.ENDC)
except (KeyboardInterrupt, SystemExit):
exit()
else:
database = DBdir +"/"+ nodeID +".db"
if not os.path.isfile(database):
open(database, 'a').close()
os.chown(database, 33, 33)
con = sqlite.connect(database)
cur = con.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS "+table+" (id INTEGER PRIMARY KEY,time INT,value TEXT);")
cur.execute("INSERT INTO "+table+" (time, value) VALUES (?,?);", (timestamp, data))con.commit()
except sqlite.Error as err:
print(c.BOLD+c.RED+"SQLite Error "+err.args[0]+c.ENDC)
except Exception as err:
print(c.BOLD+c.RED+"DB Error: "+str(err)+c.ENDC)
finally:
if con:
con.close()if __name__ == '__main__':
try:
if not os.path.exists(DBdir):
os.makedirs(DBdir)
os.chown(DBdir, 33, 33)
except OSError as ose:
print("Error creating directory '{}': {}".format(DBdir, str(ose)))
running = True
try:
ser.open()
except Exception as e:
print("Error open serial port: %s" % str(e))
if ser.isOpen():
try:
ser.flushInput() #flush input buffer, discarding all its contents
ser.flushOutput() #flush output buffer, aborting current output and discard all that is in buffer
print("Tiny Sensors with RFM12B. Waiting for Data...\r\n")
if testMode:
timestamp = int(time.time())
processData("22 v=4100&t=3421&h=6712&r=0")
processData("21 v=3099&us=321")
processData("23 v=3100&t=3487&h=6798&r=0&p=926")
processData("19 v=3000&t=4512&h=9911&r=0&p=321")
processData("10 v=4321&t2=5612")
exit()
while running:
data = ser.read(1) # read one, blocking
n = ser.inWaiting() # look if there is more
if n:
data = data + ser.read(n) # and get as much as possible
if len(data) > 0:
timestamp = int(time.time())
print("Got data: " + data)
processData(data)
except serial.SerialException as e:
print("Could not open serial port: {}".format(e))
except Exception as e1:
print("Error: " + str(e1))
except (KeyboardInterrupt, SystemExit):
print("\nSchliesse Programm..")
running = False
else:
print("Cannot open serial port")ser.close()
[/php]
Das sollte es aber auch erst mal zur TinySensor.py sein. Werde mich jetzt nur noch ums WebIf kümmern
Also das würde mich auch interessieren.
Hallo,kann mir jemand hierbei bitte weiterhelfen
![]()
Hallo,
ich hab da mal ne ganz einfache Frage.
Welches Image für den Raspberry eignet sich den am besten zum Flaschen der TinyTX ?
Aktuell nutze ich auf dem Raspi ein Openelec-Image.