MQTT learning on Pi with BME280 and node-red, node-red-dashboard

install on pi using apt
https://randomnerdtutorials.com/how-to-install-mosquitto-broker-on-raspberry-pi/
testing mqtt with pi terminal
https://randomnerdtutorials.com/testing-mosquitto-broker-and-client-on-raspbbery-pi/
using esp32
https://randomnerdtutorials.com/esp32-mqtt-publish-subscribe-arduino-ide/




becareful with the BME280 board, I have 2 kinds of board, one with a square sensor on it, this one works with adafruit library, the other one with a rectangle one, this one does not work with most of BME280 libs.

there is a post, saying adafruit library checks CHIPID of 280:
http://davidstein.cz/2017/09/30/arduino-bme280-could-not-find-a-valid-bme280-sensor-solved/
I followed it and sensor start to work.
the default address used in adafruit is 0x77, if you use 0x76, then use this:
   status = bme.begin(0x76);
Below both with default ID=0x76, the purple ones works finally, but no humidity reading with the example of adafruit, the blue one reads humidity with same code.

Image result for bme280Image result for bme280




also you need a PubSubClient library
Click here to download the PubSubClient library. You should have a .zip folder in your Downloads folder

the example  https://github.com/RuiSantosdotme/Random-Nerd-Tutorials/raw/master/Projects/ESP32-MQTT/ESP32_MQTT_Publish_Subscribe.ino

publish temp in esp32/temperature and humidity in esp32/humidity
all numbers need to be convert to array.

you can use terminal on pi to subscribe:
mosquitto_sub -d -t esp32/temperature

node-Red cames with the image of pi, but you need to start it on pi.
but not in the lite version, use this to install node-red
https://randomnerdtutorials.com/getting-started-with-node-red-on-raspberry-pi/

bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
node-Red dash board is not installed, need to install separately.
https://randomnerdtutorials.com/getting-started-with-node-red-dashboard/

and config the group to show in dash board

almost

留言

這個網誌中的熱門文章

Heltec ESP32+OLED+Lora, hardware testing

micro SD card for ESP32, on lolin32 with OLED and heltec 32 lora oled

Install Network Time Protocol(NTP) on BeagleBone with Angstrom linux and set local time zone