0

Node-Red, Pi and interfacing Adafruit hardware
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Node-Red, Pi and interfacing Adafruit hardware

by iwbaxter on Fri Feb 19, 2021 1:06 am

After a long time, I actually have a Raspberry Pi interfacing with 4* Stemma soil mosture and temperature sensors, an SGP30 for CO2 level measurement and the BME 280 for temperature and humidity in a 4X4 grow tent. I hope to take this past the prototype stage, but to be honest it is a little overwhelming.

Once I have the monitoring right, I want to move to automation (watering, lights etc).

My hardware skills are good enough, my soldering skills need more time, they werre better a long time ago.

I am fluent in many scripting languages, but the development of dashboards and automation is challenging. Until 2 weeks ago, I barely knew what Python was, Javascript I was okay with, but it failed. I had no desire to write a dashboard for this from scratch - a key reason why it took me so long to do.

IThe I2C nodes in Node-Red could not query most of the Adafruit hardware, moving to Javascript and I2C-Bus in Node.js just gave gibberish. That was another reason why it took longer than I wanted.

In this first post, I will share how to build (in very point form) how I built the base devices I have for this purpose. Leter I'll include mote detail and make it easier to understand and follow. Who's with me?
Attachments
Checklist.pdf
(582.69 KiB) Downloaded 3 times

iwbaxter
 
Posts: 6
Joined: Fri Feb 19, 2021 12:49 am

Re: Node-Red, Pi and interfacing Adafruit hardware

by iwbaxter on Sat Feb 20, 2021 8:36 pm

So, I think I have it...
Flows.txt
Current dashboard
(19.58 KiB) Downloaded 4 times

{u}Lessons learned:[/u]
Stemma soil sensor
1. Don't try to finesse the sensors in the python code. (I have one bad sensor and I think I used that for development, the newer ones - post the last upgrade seem to be working fine. With the code, simplest is best.)
2.The values will wander, I'm still not sure that I have the flows right, but using Smooth seems to work just fine - for the working sensors.
3. There is a runtime error thrown by the seesaw.py library where the deice hardware id returned is 0xd5 where 0x55 is expected. It happens at random it seems with all the sensors I have. I had to alter the code to not send the runtime error. Too many of those from a node crashes Node-Red.
4. Hand watering causes the sensors to have furry fits. It might be the soil, it might be the fertilizer. I can't wait to implement a gravity fed drip feed.

SGP30
1. ppm CO2 is reported as 400 even if it is under. Working on it.,

BME280
This darned thing rocks....

The dashboard to date:
Flows.txt
Current dashboard
(19.58 KiB) Downloaded 4 times


JSON Flows attached.
Attachments
Dashboard.JPG
Current dashboard
Dashboard.JPG (134.44 KiB) Viewed 83 times

iwbaxter
 
Posts: 6
Joined: Fri Feb 19, 2021 12:49 am

Re: Node-Red, Pi and interfacing Adafruit hardware

by iwbaxter on Sat Feb 20, 2021 8:40 pm

A visual of the nodes...

Flows.JPG
Flows.JPG (172.84 KiB) Viewed 83 times

iwbaxter
 
Posts: 6
Joined: Fri Feb 19, 2021 12:49 am

Re: Node-Red, Pi and interfacing Adafruit hardware

by iwbaxter on Sat Feb 20, 2021 8:45 pm

I am not liking this editor....

I apologize, I had intended the flows to be attached and the dashboard to be embedded. They got reversed.

I'm sure you know, now you know I do as well.

iwbaxter
 
Posts: 6
Joined: Fri Feb 19, 2021 12:49 am

Re: Node-Red, Pi and interfacing Adafruit hardware

by franklin97355 on Sat Feb 20, 2021 8:55 pm

Thanks for the work. I'm sure it will help others doing the same.

franklin97355
 
Posts: 21748
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Node-Red, Pi and interfacing Adafruit hardware

by iwbaxter on Sat Feb 20, 2021 9:45 pm

The real trick is...

1. Make it work in Python as per the Adafruit docs
2. Make sure you have the Python3 function installed
3. Use the example code from the website as a starter.

Returning the values uses a Python dictionary where msg contains a "Topic" and a "Payload"

The rest is just learning Node-Red and Python

If you are doing this all on the same I2C BUS then remember
1. The maximum length of 22 AWG unshielded is 1 meter

iwbaxter
 
Posts: 6
Joined: Fri Feb 19, 2021 12:49 am

Re: Node-Red, Pi and interfacing Adafruit hardware

by iwbaxter on Sat Feb 20, 2021 9:48 pm

Fat fingers...

Stemma - poll slowly, every 20 seconds per sensor seems optimal
Capacitance takes time to build up.
Don't trust the temp sensor, it's useful though.

I2C bus - ALWAYS stagger your transactions, give 1 second delay between transactions for the bus to clear and stabilize.

iwbaxter
 
Posts: 6
Joined: Fri Feb 19, 2021 12:49 am

Please be positive and constructive with your questions and comments.