Nishadh KA

Redeploy Dylos TDM

2014-11-05


###Redeploy Dylos in TDM###

  1. After running with the problem of excessive particle reading in UPS back up power, this note discusses its redeployment in the same station.
  2. The problem of UPS back up excessive power reading was contained by using pure sine wave UPS.
  3. In redeployment as an addition, added DHT11, humidity temperature sensor along with Dylos, RPi, USB data card setup.
  4. Attached the DHT 11 humidity temperature sensor with RPI following this as per the below picture.
  5. The reading from the DHT11 was received using a C program supplied with Adafruit learning. It compiled in different computer with a formation of bin executables named Adafruit_DHT and it was copied into the current Rpi and used. Notably, it worked without any glitches by running the command sudo ./Adafruit_DHT 11 4 .
  6. As a new measure, saved every five minutes data in sqlite3 database and communicated every 10 minutes data in SMS or HTTP post. Updated the database already used for storing Dylos reading with two more columns for storing Temperature and Humidity.
  7. Connect with SQLite database is made by the command sqlite3 dylos.db.
  8. To view the tables in the database of sqlite3. .tables;
  9. To view last updated row in sqlite3 database table data SELECT * FROM data ORDER BY SNo DESC LIMIT 1;
  10. Added a column in the table, ALTER TABLE data add column TEMP char(50);
  11. to add another column in table, ALTER TABLE data add column HUMP char(50);
  12. To view the details of table pragma table_info(data);
  13. Accessing the database from python and leaving it as without closing resultant in the data open error Error: database is locked when updating the table using the below command INSERT INTO data(data,TEMP,HUMP) VALUES('2014-11-11T14:13,111,222',1111,111);. later this was solved by restarting the RPi.
  14. The python program to serial read Dylos reading and storing it in SQLite database was updated to consider the DHT11 by subprocess the running of C bin program.

  15. To run the above program every 5 minutes used sudo crontab -e and entered a entry for the python script */5 * * * * /home/pi/SMS/data_db.py but it didn’t work, though the log entry shows starting of crontab no database save happened. Observed that there has to be a link for python script with a shell script such as this data_db.sh with content

    #!/bin/sh
    cd /home/pi/SMS
    sudo python data_db.py
    

    and made into executables by sudo chmod a+x dylos_db.py. This solved the problem and made crontab to execute the python script to run for every five minutes and storing of data in the database with Dylos reading and temp humidity data.