The Raspberry Pi will be a server for various NodeMCU ESP8266 "nodes" which will each host a temperature sensor
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
PCB.jpgThis is the final PCB! Just needs a case....JPEG Image - 2.90 MB - 09/02/2017 at 08:47 |
|
|
Components.jpgA picture of the components laid outJPEG Image - 3.02 MB - 09/02/2017 at 08:47 |
|
|
Breadboard.jpgThe breadboard test to make sure everything is functionaingJPEG Image - 1.72 MB - 09/02/2017 at 08:47 |
|
|
wiring.pngThis is the plan!Portable Network Graphics (PNG) - 140.40 kB - 09/02/2017 at 08:47 |
|
|
There is SO much you can do with such a small amount of data collected over time. However I need to start gearing up for my next project, so I am going to mark this project as "completed." For the final phase I allowed users to change the names of the sensors and added some nice labelling to the heat map. Enjoy!
I have added more sensors to the network and also added a "5 day historical comparison" feature on the web page. I can only test it fully in 5 days though...
So I have updated the web page so that the report looks much better! Mouse hovers over time were causing some weird memory issues.
One thing I did realise with deploying to the Node from another computer: You will need to install the OneWire library in Arduino (Sketch -> Include Library -> Manage Libraries):
I am hoping to call the Pi server "stable" at some point. Currently I was having wifi issues and I think that was terminating the SSH session and then the server would stop. So now I SSH over a hard LAN cable (I am using a Pi 3 for now)
I have (for the most part) finished the project. The web site and node code are fairly complete, as well as having done some more experiments. It turns out that the D8 pin on the NodeMCU ESP8266 is the problem, not the 3v3 pin as I first thought. That means I can salvage my current PCB's and make some new ones without the need for a SPDT slider switch.
There is some more code for just testing a node. I am having problems with some of the boards that I ordered from eBay and Amazon, where they throw this error:
warning: espcomm_sync failed
error: espcomm_open failed
error: espcomm_upload_mem failed
error: espcomm_upload_mem failed
I have found a diagnostic web site and a blog that have proven useful in some cases. I'll try to find a consistent solution.
I have updated the code on the repo, but unfortunately there is a slight problem: You cannot start or flash the NodeMCU chip when there is a connection to the 3v3 pin. This means I am going to need to add a switch to my PCB design. I'll update it when all the components come in from eBay.
Today I soldered the PCB together after doing a minor code check on a bread board. The particular NodeMCU boards I had bought from eBay required me to push and hold the FLASH button, press and release the RESET button, and then flashing the firmware.
I managed to burn out 2 boards when I accidentally connected A0 and D0 in series. Don't do that.
To get the NodeMCU board going with Arduino, you need to add:
http://arduino.esp8266.com/stable/package_esp8266com_index.json
To the additional boards manager in preferences. You will also need to then go to the boards manager and download the ESP8266 components. If you can't see the port your board is connected to, download the driver from here:
https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
I had also added the OneWire library to my Arduino: http://www.arduinolibraries.info/libraries/one-wire
Then the basic code was fairly simple:
#include <OneWire.h>
#define DS18S20_Pin D8
#define BLUE_PIN D6
#define GREEN_PIN D5
#define RED_PIN D4
OneWire ds(DS18S20_Pin);
int CURRENT_COL = RED_PIN;
void setup() {
Serial.begin(115200);
Serial.println("");
Serial.println("Hello ESP8266");
pinMode(LED_BUILTIN, OUTPUT);
pinMode(RED_PIN, OUTPUT);
pinMode(GREEN_PIN, OUTPUT);
pinMode(BLUE_PIN, OUTPUT);
}
float getTemp(){
//returns the temperature in Celsius
byte data[12];
byte addr[8];
if ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.reset_search();
return -1001;
}
if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1002;
}
if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1003;
}
ds.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end
byte present = ds.reset();
ds.select(addr);
ds.write(0xBE); // Read Scratchpad
for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}
ds.reset_search();
byte MSB = data[1];
byte LSB = data[0];
float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;
return TemperatureSum;
}
void loop() {
digitalWrite(RED_PIN, LOW);
digitalWrite(GREEN_PIN, LOW);
digitalWrite(BLUE_PIN, LOW);
digitalWrite(CURRENT_COL,
HIGH);
digitalWrite(LED_BUILTIN, LOW);
Serial.println("LED OFF");
delay(1000);
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("LED ON");
delay(500);
float temperature = getTemp();
String temp = String(temperature);
Serial.print("TEMPERATURE: ");
Serial.println(temp);
delay(250);
if (CURRENT_COL == RED_PIN) {
CURRENT_COL = BLUE_PIN;
} else if (CURRENT_COL == BLUE_PIN){
CURRENT_COL = GREEN_PIN;
} else {
CURRENT_COL = RED_PIN;
}
}
All this does is print the temperature to the serial and cycles through the RED, GREEN and BLUE colours
Create an account to leave a comment. Already have an account? Log In.
Become a member to follow this project and never miss any updates