For an index to all my stories click this text.
What we are going to do.
We are going to build an IOT dashboard with Freeboard that can be freely arranged by yourself.
As you can see the dashboard has a field displaying time. Gauges that give the temperature inside the house and outside. A graph displaying the temperature. Buttons for putting lamps on and off and indicator leds that show if people are in and if apparatus are functioning or off-line. You can add many more widgets to build a complete Home automation system.
This is going to be a multiple story project, so keep following this blog and see how we get Freeboard working with a lot more options as what the standard version offers.
Freeboard
Looong time ago (oktober 2019) I published a story about Freeboard. You can re-read that here: http://lucstechblog.blogspot.com/2019/10/freeboard.html
Freeboard was free at that time. Meaning anybody could sign up and use the service for free. You could build your dashboards and use ESP's to send data to them.
And then things changed. Suddenly the makers of Freeboard decided that the service could not be used for free anymore. This bothered me a lot cause I wrote a story on Freeboard and suddenly readers that got enthousiastic and started using it had to pay for it.
And then, sometime ago, I stumbled upon a story about a programming service called Bipes. Bipes works with programming blocks (just like MIT's App Inventor) which are translated into MicroPython and sends the code to your Microcontroller which can be an ESP (8266 or 32) or a Raspberry Pi Pico. Bipes in itself is somewhat interesting and maybe worth having a look at. You can find it here: http://bipes.net.br/beta2/ui/
If you read from the above lines that I am a bit reluctant to get further into this then you are right. These services (there are more like Bipes) are totally dependent on their makers. So libraries and sensors are only added when the makers decide so. Which makes you dependent.
The interesting part though was that Bipes included Freeboard for displaying sensor data. And the author claimed that it was easy to install Freeboard in your own projects. But he did not get into that. And so started my search.
Freeboard on Github.
I found Freeboard on Github: https://github.com/Freeboard/freeboard Then I saw that the makers of Freeboard had a demo version set up on Github: http://freeboard.github.io/freeboard/ I immediately started testing this demo version and it worked flawless.
The Freeboard page stated that Freeboard was published on Github under the MIT license. I looked into that license and it has the following statement:
Copyright (c) <year> <copyright holders>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Now that opens perspectives !!! So I immediately forked Freeboard to my own repositry.
Some time ago I wrote a story on how to use Github as a web-server for your own web-pages. You can re-read that story here.
http://lucstechblog.blogspot.com/2023/07/using-github-for-building-website.html
And that is what I did with my own repositry. I made a web-page from the repositry.
And yes it started.
So I added my faithfull thermometer which was after all these years still sending data to Dweet. Weather stations and thermometers are really stupid things. Just look out of your window or go outside and you feel what the temperature is. No need for electronics to tell me. Still I have an electronic thermometer as it is a constant data source which can be used for testing purposes like now...... So let´s have a look at how my thermometer Dweets. My ´Thing´ is called Lucstemp2018 and the thermometer value is in the variable `temp´. Let us use that.
Short intermezzo.
Freeboard uses (amongst others) Dweet to store data on and get data from. If you do not know what Dweet is and how to use it please read these stories:
https://lucstechblog.blogspot.com/2019/05/dweet-volatile-iot-cloud-service.html
https://lucstechblog.blogspot.com/2019/08/dweet-again.html
http://lucstechblog.blogspot.com/2019/12/dweet-with-arduino.html
The thermometer I am using is build with an ESP-01 and a Dallas DS18B20 temperature sensor. It is programmed in ESP-Basic and has been running since 2017. Story, schematics and program can be found here:
http://lucstechblog.blogspot.com/2017/11/oh-no-not-another-wifi-thermometer.html
I use the thermometer to send data to my Domoticz setup, Thingspeak and Dweet. The Dweet part is the most interesting for use with Freeboard. You can re-read how that's done here: https://lucstechblog.blogspot.com/2019/08/dweet-again.html
Something is wrong !!!
I thought that all was OK but it was not.
As you can see Freeboard is not getting the Thermometers value. It never updates its value. So where did I go wrong ???
Back to the Github demo from Freeboard itself. And hey that works ???????
So I send a requets to the makers of Freeboard on Github.
https://github.com/Freeboard/freeboard/issues/283
Within a day they responded with a suggestion, which I tried immediately. But alas it did not work.
And then I had an idea. I carefully looked at the url's that were used in Freeboards github page and mine.
This is the Freeboard URL
And this is mine.
Spot the difference ????
Well Freeboard's Github page is HTTP and mine is HTTPS.
When the Freeboard Github page was made Github allowed webpages to be HTTP. And now they only allow HTTPS (secure) pages. There is the difference.
Therefore Freeboard will not work as a GitHub webpage.
So I had to find another web-service that allowed me to setup a webpage as a HTTP page. And That was easier as I imagined. Read how to achieve this in an upcoming story.
Till that time dive into Freeboard with the Freeboard Github version http://freeboard.github.io/freeboard/ and look at all the possibilities. Freeboard is fun and an easy way to build an IOT dashboard. And re-read my first story about Freeboard which will help you setting up your own Dashboard: http://lucstechblog.blogspot.com/2019/10/freeboard.html
Till next time.
Have fun
Luc Volders
Showing posts with label ESP8266-Basic. Show all posts
Showing posts with label ESP8266-Basic. Show all posts
Friday, August 4, 2023
Freeboard revisisted part 1
Labels:
Domotics,
ESP-01,
ESP32,
ESP8266,
ESP8266-Basic,
IOT,
Javascript,
NodeMCU
Friday, March 18, 2022
More buttons on fewer pins
For an index to all my stories click this text
I am working at at larger project in which I need an ESP8266 to send certain data over wifi depending on buttons being pressed. Nothing exiting you might think. However in one particular case I might need a lot of buttons.
The ESP8266 boards like a NodeMCU module or a Wemos D1 have about 11 digital I/O ports available. So I could attach a button to each I/O pin giving me 11 buttons. However that leaves no room for attaching other items like control-leds or a display.
It gets worse when you are working with really tiny controllers like the Attiny85. This micro-controller has, when normally used, just 5 I/O pins.
Let's have a look how the commercially available keyboards work.


As you can see they are build in a matrix layout. The 4 x 4 matrix has 4 rows and 4 columns. In the software you make sure that one of the rows is set to LOW, the rest to HIGH. This way you can test which column gets the LOW signal and that intersection is the key being pressed. If none of the columns gets a LOW signal the next row is set to LOW and the test starts over.
This works great however has some flaws for me. First the software makes the controller load high. You actively have to set each row in its turn LOW and the rest HIGH and then test which column gets the LOW signal. This will keep your controller pretty busy.
Next to that for 12 buttons you will need 7 I/O pins. For 16 buttons you will need 8 pins. This leaves little room for control leds although I could use neopixels for that which only take one I/O port. And this is no option for working with an Attiny85 with its mere 5 I/O pins.
I needed something better. So started thinking.
The binary system.
Let's look at the binary system. If I have one wire it can be HIGH or LOW. When using two wires there are already more possibilities:
LOW LOW
LOW HIGH
HIGH LOW
HIGH HIGH
So how do I put that to use. Lets attach switches to the 2 wires using this principle.
Look at the schematic. The two pull up resistors make sure that if no key is pressed both lines are HIGH. That is the HIGH-HIGH state.
There are three buttons.
The first button is connected to the first line, second button to the second and third button to both.
The idea is ok but it just does not work. If you press button one the ground will indeed be connected to the first line, but it will flow through the wire connected to button three. And as this button is connected to both wires, so ground will be connected to both wires.
We have to prevent that ground will be connected to two wires at the same time and that is easy.
Just put diodes on the wires connected to the buttons.
If you press button 1 ground will be connected to line 1. Ground wants to flow to button three but is prevented by the diode so can not flow back to line 2.
That is it. So with two lines we can use three switches.

Above you can see the breadboard setup. And best part: it really works.
The binary system with 3 wires
Using 3 wires we have the following posibillities:
LOW LOW LOW
LOW LOW HIGH
LOW HIGH LOW
LOW HIGH HIGH
HIGH LOW LOW
HIGH LOW HIGH
HIGH HIGH LOW
HIGH HIGH HIGH
Leaving the last one out because that is when no button is pressed, we have 7 posibillities. So 7 buttons with just 3 wires.
Lets look at the schematics again.

Not a lot different from our fist setup with only two wires.
Does it look familiar somewhere ???
Well if you are a faithfull reader of this blog you might recognise this from my stories on Charlieplexing. The hardware setup is not quite the same but it has some resemblance. You can re-read that story here:
https://lucstechblog.blogspot.com/2017/09/charlieplexing.html or search my index page for all the Charlieplexing stories: http://lucstechblog.blogspot.com/p/index-of-my-stories.html
Adding visual feedback
I wanted a visual feedback for testing purposes. For that I added a string of 7 neopixels. The reason is obvious: attaching a bunch of neopixels can be done with just 1 I/O pin. For those not familiar with the term: neopixels are adressable RGB leds officially called WS2812. For basic information on Neopixels re-read this story: http://lucstechblog.blogspot.com/2015/10/neopixels-ws2812-intro.html
The software.
Let's start with the software in Arduino IDE (C++).
Before I get a load of comments in my mail on this code let me make it clear that this source code can be optimised a lot. That would make it a lot more complicated for beginning programmers to comprehend. So adjust it for your own purposes.
The program starts with initialising the Neopixel library and attaching the library to pin D8.
In the setup routine the input lines D5, D6 and D7 are defined, and we attach an interrupt to each of these lines. All the interrupts point to the same routine: buttonpress on a FALLING signal. This means that when a button is pressed (connected to ground) the program starts the interrupt routine.
This is a big advantage over the software for the commercial keyboards. Your software is not constant sending LOW signals to row-pins and polling the collumn-pins. We just wait till a key is pressed and in the mean time the micro-controller has loads of time for other tasks.
When a button is pressed the program jumps to the buttonpress() routine.
Here is a closer examination about what happens when button 4 is pressed:
// button 4 ==> 100
if (digitalRead(D5)== HIGH && digitalRead(D6)== LOW && digitalRead(D7)== LOW) //
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,255,0);
strip.setPixelColor(3, 0,255,0);
strip.setPixelColor(4, 0,0,0);
strip.setPixelColor(5, 0,0,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
The diodes from button 4 are attached to D6 and D7. So when button 4 is pressed D5 will get no signal and the pull-up resistor makes sure the line is HIGH. Line D6 and D7 will be connected to ground. This is what the if statement analyses.
Next part is just setting 4 of the neopixels to green, so we know for sure button 4 is pressed. The delay makes sure that the neopixels are lit before we go on.
Simple and efficient !!!
We got lots of room and time for the processor to perform other tasks in stead of constant sending signals and polling lines and have the risk of missing a keypress.
You will notice that the only thing you have to do is to alter D5, D6, D7 and D8 and this will also work on the ESP32 or any of the Arduino family even on the humble Attiny85 !!!
Basic program
No I am not forgetting ESP-Basic, - my used to be - favorite rapid devellopment environment (that's a mouth full). In fact the hardware setup is so efficient that writing the software in Basic is very easy. It looks a lot like the C++ program.
A quick examination of the program:
interrupt d5, [CHANGE]
interrupt d6, [CHANGE]
interrupt d7, [CHANGE]
neo.setup(d8)
neo.cls()
wait
This is the main part where the interrupts are defined and the neopixels are attached to IO pin D8
[CHANGE]
interrupt d5
interrupt d7
interrupt d6
This is a tricky part.
If the [CHANGE] routine is called (as a button is pressed) we do not want that the routine is accidentally (think bouncing buttons) called again. So these commands disable the interrupts.
if ((io(pi,d5) = 1) and (io(pi,d6) = 0) and (io(pi,d7) = 0)) then
neo.cls()
neo(0,0,0,250)
neo(1,0,0,250)
neo(2,0,0,250)
neo(3,0,0,250)
endif
This is almost the same as in the C++ routine and is the part where button 4 is processed.
As you can see D5 gets no signal so that will be pulled HIGH by the pull-up resistors. D6 and D7 should both get a LOW signal. If this is true the first 4 neopixels (0 to 3) will be set to blue.
interrupt d6, [CHANGE]
interrupt d7, [CHANGE]
interrupt d5, [CHANGE]
These lines will activate the interrupts anew when the routine has finished.
As there are two delay (500) statements the program will register a button-press once every second. That should be fast enough for most purposes.
Expanding
Using 4 I/O pins you can attach 15 buttons which is enough for a simple calculator keyboard. And with 5 I/O pins you can attach 31 buttons !!
I am sure you can work the schematics out for yourselves.
Let's elaborate on this.
With 5 I/O pins you can attach 31 buttons. Now suppose you use one of these 31 buttons as a Shift key and another one as a Second Function key you could build a simple ASCII keyboard using an Arduino Pro Micro which has a real USB interface.
Pros and cons.
So why isn't this used more often, and why are all the commercial keyboards build as a matrix ssytem and not in this way.
The answer is simple: costs.
Using the matrix layout you only need buttons. In this setup you need buttons and diodes which is more expensive and makes the PCB a bit more complicated.
The pros for me weigh much more as the cons.
For the 12 button commercial version you will need to use 7 I/O pins on your controller. I only need 4 and can use 15 buttons (3 more).
The additional costs are so small that they are neglectable. At the moment of this writing you can buy 100 diodes for 50 cents !!!
Next to that the software does not put a heavy load on my controller and is much easier to program.
And last but not least: on an Attiny85 I can attach 15 buttons and a string of neopixels at the same time !!!
Real world setup
Above you can see my real world setup and test. The only difference with the schematics in this story is that I attached a seperate power supply for the Neopixels.
That's it for now.
Till next time and have fun.
Luc Volders
I am working at at larger project in which I need an ESP8266 to send certain data over wifi depending on buttons being pressed. Nothing exiting you might think. However in one particular case I might need a lot of buttons.
The ESP8266 boards like a NodeMCU module or a Wemos D1 have about 11 digital I/O ports available. So I could attach a button to each I/O pin giving me 11 buttons. However that leaves no room for attaching other items like control-leds or a display.
It gets worse when you are working with really tiny controllers like the Attiny85. This micro-controller has, when normally used, just 5 I/O pins.
Let's have a look how the commercially available keyboards work.


As you can see they are build in a matrix layout. The 4 x 4 matrix has 4 rows and 4 columns. In the software you make sure that one of the rows is set to LOW, the rest to HIGH. This way you can test which column gets the LOW signal and that intersection is the key being pressed. If none of the columns gets a LOW signal the next row is set to LOW and the test starts over.
This works great however has some flaws for me. First the software makes the controller load high. You actively have to set each row in its turn LOW and the rest HIGH and then test which column gets the LOW signal. This will keep your controller pretty busy.
Next to that for 12 buttons you will need 7 I/O pins. For 16 buttons you will need 8 pins. This leaves little room for control leds although I could use neopixels for that which only take one I/O port. And this is no option for working with an Attiny85 with its mere 5 I/O pins.
I needed something better. So started thinking.
The binary system.
Let's look at the binary system. If I have one wire it can be HIGH or LOW. When using two wires there are already more possibilities:
LOW LOW
LOW HIGH
HIGH LOW
HIGH HIGH
So how do I put that to use. Lets attach switches to the 2 wires using this principle.
Look at the schematic. The two pull up resistors make sure that if no key is pressed both lines are HIGH. That is the HIGH-HIGH state.
There are three buttons.
The first button is connected to the first line, second button to the second and third button to both.
The idea is ok but it just does not work. If you press button one the ground will indeed be connected to the first line, but it will flow through the wire connected to button three. And as this button is connected to both wires, so ground will be connected to both wires.
We have to prevent that ground will be connected to two wires at the same time and that is easy.
Just put diodes on the wires connected to the buttons.
If you press button 1 ground will be connected to line 1. Ground wants to flow to button three but is prevented by the diode so can not flow back to line 2.
That is it. So with two lines we can use three switches.

Above you can see the breadboard setup. And best part: it really works.
The binary system with 3 wires
Using 3 wires we have the following posibillities:
LOW LOW LOW
LOW LOW HIGH
LOW HIGH LOW
LOW HIGH HIGH
HIGH LOW LOW
HIGH LOW HIGH
HIGH HIGH LOW
HIGH HIGH HIGH
Leaving the last one out because that is when no button is pressed, we have 7 posibillities. So 7 buttons with just 3 wires.
Lets look at the schematics again.

Not a lot different from our fist setup with only two wires.
Does it look familiar somewhere ???
Well if you are a faithfull reader of this blog you might recognise this from my stories on Charlieplexing. The hardware setup is not quite the same but it has some resemblance. You can re-read that story here:
https://lucstechblog.blogspot.com/2017/09/charlieplexing.html or search my index page for all the Charlieplexing stories: http://lucstechblog.blogspot.com/p/index-of-my-stories.html
Adding visual feedback
I wanted a visual feedback for testing purposes. For that I added a string of 7 neopixels. The reason is obvious: attaching a bunch of neopixels can be done with just 1 I/O pin. For those not familiar with the term: neopixels are adressable RGB leds officially called WS2812. For basic information on Neopixels re-read this story: http://lucstechblog.blogspot.com/2015/10/neopixels-ws2812-intro.html
The software.
Let's start with the software in Arduino IDE (C++).
#include <Adafruit_NeoPixel.h>
#define PIXEL_PIN D8
#define PIXEL_COUNT 7
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
void setup()
{
pinMode(D5, INPUT);
pinMode(D6, INPUT);
pinMode(D7, INPUT);
attachInterrupt(digitalPinToInterrupt(D5), buttonpress, FALLING);
attachInterrupt(digitalPinToInterrupt(D6), buttonpress, FALLING);
attachInterrupt(digitalPinToInterrupt(D7), buttonpress, FALLING);
strip.begin();
strip.show();
}
void loop()
{
}
void buttonpress()
{
// button 1 ==> 011
if (digitalRead(D5)== LOW && digitalRead(D6)== HIGH && digitalRead(D7)== HIGH)
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,0,0);
strip.setPixelColor(2, 0,0,0);
strip.setPixelColor(3, 0,0,0);
strip.setPixelColor(4, 0,0,0);
strip.setPixelColor(5, 0,0,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
// button 2 ==> 101
if (digitalRead(D5)== HIGH && digitalRead(D6)== LOW && digitalRead(D7)== HIGH)
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,0,0);
strip.setPixelColor(3, 0,0,0);
strip.setPixelColor(4, 0,0,0);
strip.setPixelColor(5, 0,0,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
// button 3 ==> 110
if (digitalRead(D5)== HIGH && digitalRead(D6)== HIGH && digitalRead(D7)== LOW)
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,255,0);
strip.setPixelColor(3, 0,0,0);
strip.setPixelColor(4, 0,0,0);
strip.setPixelColor(5, 0,0,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
// button 4 ==> 100
if (digitalRead(D5)== HIGH && digitalRead(D6)== LOW && digitalRead(D7)== LOW) //
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,255,0);
strip.setPixelColor(3, 0,255,0);
strip.setPixelColor(4, 0,0,0);
strip.setPixelColor(5, 0,0,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
// button 5 ==> 001
if (digitalRead(D5)== LOW && digitalRead(D6)== LOW && digitalRead(D7)== HIGH) //
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,255,0);
strip.setPixelColor(3, 0,255,0);
strip.setPixelColor(4, 0,255,0);
strip.setPixelColor(5, 0,0,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
// button 6 ==> 010
if (digitalRead(D5)== LOW && digitalRead(D6)== HIGH && digitalRead(D7)== LOW) //
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,255,0);
strip.setPixelColor(3, 0,255,0);
strip.setPixelColor(4, 0,255,0);
strip.setPixelColor(5, 0,255,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
// button 7 ==> 000
if (digitalRead(D5)== LOW && digitalRead(D6)== LOW && digitalRead(D7)== LOW) //
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,255,0);
strip.setPixelColor(3, 0,255,0);
strip.setPixelColor(4, 0,255,0);
strip.setPixelColor(5, 0,255,0);
strip.setPixelColor(6, 0,255,0);
strip.show();
delay(500);
}
}
Before I get a load of comments in my mail on this code let me make it clear that this source code can be optimised a lot. That would make it a lot more complicated for beginning programmers to comprehend. So adjust it for your own purposes.
The program starts with initialising the Neopixel library and attaching the library to pin D8.
In the setup routine the input lines D5, D6 and D7 are defined, and we attach an interrupt to each of these lines. All the interrupts point to the same routine: buttonpress on a FALLING signal. This means that when a button is pressed (connected to ground) the program starts the interrupt routine.
This is a big advantage over the software for the commercial keyboards. Your software is not constant sending LOW signals to row-pins and polling the collumn-pins. We just wait till a key is pressed and in the mean time the micro-controller has loads of time for other tasks.
When a button is pressed the program jumps to the buttonpress() routine.
Here is a closer examination about what happens when button 4 is pressed:
// button 4 ==> 100
if (digitalRead(D5)== HIGH && digitalRead(D6)== LOW && digitalRead(D7)== LOW) //
{
strip.setPixelColor(0, 0,255,0);
strip.setPixelColor(1, 0,255,0);
strip.setPixelColor(2, 0,255,0);
strip.setPixelColor(3, 0,255,0);
strip.setPixelColor(4, 0,0,0);
strip.setPixelColor(5, 0,0,0);
strip.setPixelColor(6, 0,0,0);
strip.show();
delay(500);
}
The diodes from button 4 are attached to D6 and D7. So when button 4 is pressed D5 will get no signal and the pull-up resistor makes sure the line is HIGH. Line D6 and D7 will be connected to ground. This is what the if statement analyses.
Next part is just setting 4 of the neopixels to green, so we know for sure button 4 is pressed. The delay makes sure that the neopixels are lit before we go on.
Simple and efficient !!!
We got lots of room and time for the processor to perform other tasks in stead of constant sending signals and polling lines and have the risk of missing a keypress.
You will notice that the only thing you have to do is to alter D5, D6, D7 and D8 and this will also work on the ESP32 or any of the Arduino family even on the humble Attiny85 !!!
Basic program
No I am not forgetting ESP-Basic, - my used to be - favorite rapid devellopment environment (that's a mouth full). In fact the hardware setup is so efficient that writing the software in Basic is very easy. It looks a lot like the C++ program.
interrupt d5, [CHANGE]
interrupt d6, [CHANGE]
interrupt d7, [CHANGE]
neo.setup(d8)
neo.cls()
wait
[CHANGE]
interrupt d5
interrupt d7
interrupt d6
if ((io(pi,d5) = 0) and (io(pi,d6) = 1) and (io(pi,d7) = 1)) then
neo.cls()
neo(0,250,250,250)
endif
if ((io(pi,d5) = 1) and (io(pi,d6) = 0) and (io(pi,d7) = 1)) then
neo.cls()
neo(0,250,250,250)
neo(1,250,250,250)
endif
if ((io(pi,d5) = 1) and (io(pi,d6) = 1) and (io(pi,d7) = 0)) then
neo.cls()
neo(0,250,250,250)
neo(1,250,250,250)
neo(2,250,250,250)
endif
if ((io(pi,d5) = 1) and (io(pi,d6) = 0) and (io(pi,d7) = 0)) then
neo.cls()
neo(0,0,0,250)
neo(1,0,0,250)
neo(2,0,0,250)
neo(3,0,0,250)
endif
if ((io(pi,d5) = 0) and (io(pi,d6) = 0) and (io(pi,d7) = 1)) then
neo.cls()
neo(0,250,0,0)
neo(1,250,0,0)
neo(2,250,0,0)
neo(3,250,0,0)
neo(4,250,0,0)
endif
if ((io(pi,d5) = 0) and (io(pi,d6) = 1) and (io(pi,d7) = 0)) then
neo.cls()
neo(0,0,250,0)
neo(1,0,250,0)
neo(2,0,250,0)
neo(3,0,250,0)
neo(4,0,250,0)
neo(5,0,250,0)
endif
if ((io(pi,d5) = 0) and (io(pi,d6) = 0) and (io(pi,d7) = 0)) then
neo.cls()
neo(0,250,0,250)
neo(1,250,0,250)
neo(2,250,0,250)
neo(3,250,0,250)
neo(4,250,0,250)
neo(5,250,0,250)
neo(6,250,0,250)
endif
delay (500)
interrupt d6, [CHANGE]
interrupt d7, [CHANGE]
interrupt d5, [CHANGE]
delay (500)
cls
wait
end
A quick examination of the program:
interrupt d5, [CHANGE]
interrupt d6, [CHANGE]
interrupt d7, [CHANGE]
neo.setup(d8)
neo.cls()
wait
This is the main part where the interrupts are defined and the neopixels are attached to IO pin D8
[CHANGE]
interrupt d5
interrupt d7
interrupt d6
This is a tricky part.
If the [CHANGE] routine is called (as a button is pressed) we do not want that the routine is accidentally (think bouncing buttons) called again. So these commands disable the interrupts.
if ((io(pi,d5) = 1) and (io(pi,d6) = 0) and (io(pi,d7) = 0)) then
neo.cls()
neo(0,0,0,250)
neo(1,0,0,250)
neo(2,0,0,250)
neo(3,0,0,250)
endif
This is almost the same as in the C++ routine and is the part where button 4 is processed.
As you can see D5 gets no signal so that will be pulled HIGH by the pull-up resistors. D6 and D7 should both get a LOW signal. If this is true the first 4 neopixels (0 to 3) will be set to blue.
interrupt d6, [CHANGE]
interrupt d7, [CHANGE]
interrupt d5, [CHANGE]
These lines will activate the interrupts anew when the routine has finished.
As there are two delay (500) statements the program will register a button-press once every second. That should be fast enough for most purposes.
Expanding
Using 4 I/O pins you can attach 15 buttons which is enough for a simple calculator keyboard. And with 5 I/O pins you can attach 31 buttons !!
I am sure you can work the schematics out for yourselves.
Let's elaborate on this.
With 5 I/O pins you can attach 31 buttons. Now suppose you use one of these 31 buttons as a Shift key and another one as a Second Function key you could build a simple ASCII keyboard using an Arduino Pro Micro which has a real USB interface.
Pros and cons.
So why isn't this used more often, and why are all the commercial keyboards build as a matrix ssytem and not in this way.
The answer is simple: costs.
Using the matrix layout you only need buttons. In this setup you need buttons and diodes which is more expensive and makes the PCB a bit more complicated.
The pros for me weigh much more as the cons.
For the 12 button commercial version you will need to use 7 I/O pins on your controller. I only need 4 and can use 15 buttons (3 more).
The additional costs are so small that they are neglectable. At the moment of this writing you can buy 100 diodes for 50 cents !!!
Next to that the software does not put a heavy load on my controller and is much easier to program.
And last but not least: on an Attiny85 I can attach 15 buttons and a string of neopixels at the same time !!!
Real world setup
Above you can see my real world setup and test. The only difference with the schematics in this story is that I attached a seperate power supply for the Neopixels.
That's it for now.
Till next time and have fun.
Luc Volders
Labels:
Arduino,
Attiny85,
Charlieplexing,
Electronics,
ESP32,
ESP8266,
ESP8266-Basic,
Neopixels,
NodeMCU
Friday, February 7, 2020
ESP8266 sending data to Domoticz
For a complete index to all my stories click this text !!
If you have not heard about Domoticz by now it is time you should.
Domoticz is a complete home automation system that is open source and free for you to download. It runs on Apple, Windows, Linux and last but not least Raspberry. You can find the web-page here: http://www.domoticz.com/
My system is running on a Raspberry 2B with some extra hardware called RF-Link. My RF-Link clone an Arduino Mega with a 433Mhz Transmitter and Receiver. This makes it possible for Domoticz to communicate with Klik-Aan-Klik-Uit and other cheap 433 Mhz switches, doorbells, blinds, weatherstations etc.
Domoticz itself communicates with systems like Philips Hue, Sonos, Anslut (Ikea lights), Mi-Light etc etc etc etc. You can find a complete list of brands and devices on the Domoticz Wiki Page:
https://www.domoticz.com/wiki/Hardware
The Domoticz software is controlled from a webpage that can be accessed by your PC and there are Android App's available to control it from your tablet or phone.
You can even make rules like switch the TV on, close the curtains, switch the home-cinema on and dim the lights. So with one button your set for a move evening.
Summarising: with Domoticz you have a complete system to automate your home which will set you back around 60 euro.
I bought some cheap 433 Mhz switches and automated the lights in my hobby room, living room and with christmass I switch on the christmass-tree and all related lamps from anywhere with the App on my phone.
This is all great but I wanted more.
In all the years I am tinkering I build several projects with led-strips, sensors like a rain-sensor, door and window sensors, a thermometer etc. I want them all to be controlled from Domoticz.
Next to that I want to build some special switches. For example a switch with an LDR that tests the light in a room and automatically puts on the lamps when needed. Or a switch that puts a lamp on when someone enters a room. You can do all this with individual switches. But it is neat to have one central place where it all comes together.
As an add-on for Domoticz someone started a project called ESP-Easy ( https://www.letscontrolit.com/ ) that makes it easy to attach sensors to an ESP8266 and connect that to Domoticz. A really neat project so check it out.
However I want to do things myself and presumably you to otherwise you would stop reading from here.
So what I am going to show you here is how a button pressed on the ESP8266 sends a command to Domoticz which then sends a command to a 433Mhz light switch. Great for making remote controls for Domoticz. And next I am going to make a temperature sensor that sends it's data to Domoticz.
Intermezzo
I am moving away from ESP-Basic. It is no longer maintained nor updated. And there is no ESP32 version available. So I am building most of my new projects in the Arduino IDE (C++). I must admit that writing and develloping programs in ESP-Basic is faster as writing and debugging in C++. There are however a lot of nice sensors and add-ons available now which are not supported in ESP-Basic. So this story will be one of the last ones in which the program is in ESP-Basic.
ESP on screen button as remote for Domoticz
First thing we are going to build is an ESP8266 that creates a webpage on which a button can be clicked that sends information to Domoticz. In my setup I have a 433 Mhz lightswitch that controls a lamp in my hobbyroom which I am going to control this way.
Start with looking in Domoticz at the devices list for the switch you want to control. I wanted to control "Lucs room lampje" which has IDX number 3. We need that number to put in our program.
To control this switch we need to call a Domoticz API. You can find a list off all Domoticz API's here: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
On this page look for the entry : Turn a light/switch on
There you will find the required API call:
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=On
So what we need to do is to build a webpage with a button on it and when that button is pressed this code is send to Domoticz. And that is easily done with ESP-Basic.
For those of you who have no experience with ESP-Basic I urge you to read this tutorial which will have you up and running in no time:
http://lucstechblog.blogspot.nl/2017/03/back-to-basic-basic-language-on-esp8266.html
And here is the program.
Let's have a look at this.
The program starts with putting some text on the screen and two buttons for ON and OFF.
When one of the buttons is pressed the program jumps to the accompanying routine wich calls the API. As described above the API looks like this:
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=On
and that is translated in ESP-Basic in this:
query = "192.168.1.66/json.htm?type=command&"
query = query & "param=switchlight&idx=3&switchcmd=On"
ret = wget(query,8080)
query is the variable in which the data is collected that is going to be send. 192.168.1.66 is the IP number of my Domoticz setup. You have to replce that with your own IP. The rest of the API call is just copied except the IDX number which I altered in the number of my switch: 3
The wget statement sends the API call and puts the answer in the ret variable. You do not need to add this line but if you do not any info that Domoticz send back is displayed on the screen which makes a mess of your screen.
I do not think that it can be programmed in any other language for the ESP more easier.
And this is the result on your computer / phone / tablet's screen.
The buttons Lamp on and Lamp off switches lucs room lampje on or of and that can bee seen in Domoticz and off course by just looking at the lamp.
Temperature Sensor
I also wanted to send some sensor data to Domoticz. So I attached a Dallas DS18B20 temperature sensor to the ESP8266 (NodeMCU board) to see if I could get some readings.
To setup a switch or sensor in Domotics that is not physical attached but gets it's data through wifi you will have to define a virtual switch.
First in Domoticz open the devices tab and create a virtual switch. Give it a name. I choose Virtueel 3 and choose as type Dummy.
Now choose create virtual sensor I gave it as name Test temperature and as sensor type Temperature
At this moment the sensor is already visible in the Temperature Tab of Domoticz although it does not have received any value and therefore the temperature will be 0
Go back to the devices menu (Apparaten in Dutch) and there you can find Virtueel 3 and as you can see that the ID number is 4592
Next step is to build the hardware
My test setup is just a DS18B20 with a pull-up resistor of 4.7K attached to GPIO2 (D4) of a NodeMCU board.
In ESP-Basic I wrote a small test pogram to see if the sensor worked.
Nothing special. The program just reads temp(0) which is the DS18b20 and puts the value on the screen.
Back to the Domoticz API page on the web: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Create_a_virtual_sensor
Here we can read how the API call looks for reading a sensor.
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
TEMP = Temperature
So we just need to implement that in our ESP-Basic program. Here you go:
Again very easy to implement.
A timer is setup that every 5 minutes calls the [domoticztemp] routine.
Timer 1000 * 60 * 5 = every 5 minutes
The formula is simple. ESP's timer works in miliseconds. So 1000 = 1 second (1000 miliseconds). 60 Seconds in a minute and that times 5 minutes.
Why the 5 minute routine ? Well Domoticz just displays the sensors reading once in the 5 minutes on it's screen.
And there you go: the temperature is displayed in Domoticz.
Last step: Combine button and Temperature
A NodeMCU or a Wemos D1 have many I/O ports. Why not use them ? So let's combine the button and the temperature programs and include a physical button as well.
Again the hardware setup is easy. I took the temperature setup and added a button that is connected with a pull-up resistor (10k) to D3 of the NodeMCU board.
No surprises in the software either. An interrupt tests wether the button has been pressed and jumps to the [change] routine.
but = 1 - but
This line toggles the but value between 0 and 1 for setting the switch ON or OFF.
The rest is the same as in the previous programs.
This is how it looks on the screen of your computer / phone / tablet.
Hey, what's that Luc's Room Temperatuur thing ???
Well remember my "Oh no, not another wifi thermometer." entry in this weblog. If not you can re-read that story here: http://lucstechblog.blogspot.nl/2017/11/oh-no-not-another-wifi-thermometer.html
As you might remember this thermometer not only set's its data on the screen of a webpage but it also sends it's data to Thingspeak. To refresh your memory you can re-read the weblog entry here:
http://lucstechblog.blogspot.nl/2017/11/thingspeak.html
Well that thermometer has been sending it's data also for a long time now to my Domoticz setup.
Here is the altered code for that Thermometer.
As you can see the temperature is not only put on a webpage accessible from your computer/phone/tablet but also send to Thingspeak like described in this story:
http://lucstechblog.blogspot.nl/2017/11/thingspeak.html
And now it also sends the data to Domoticz, using the same code as described above with just another IDX.
The chart shows you that the thermometer has been working continuously from july 2017. This shows how reliable the ESP8266 and ESP-Basic is.
As stated in the beginning of this story: I am moving away from ESP-Basic to the Arduino IDE (C++). So in upcoming stories I'll be showing you how to achieve this in C++. So stay tuned.
Till then
have fun
Luc Volders
If you have not heard about Domoticz by now it is time you should.
Domoticz is a complete home automation system that is open source and free for you to download. It runs on Apple, Windows, Linux and last but not least Raspberry. You can find the web-page here: http://www.domoticz.com/
My system is running on a Raspberry 2B with some extra hardware called RF-Link. My RF-Link clone an Arduino Mega with a 433Mhz Transmitter and Receiver. This makes it possible for Domoticz to communicate with Klik-Aan-Klik-Uit and other cheap 433 Mhz switches, doorbells, blinds, weatherstations etc.
Domoticz itself communicates with systems like Philips Hue, Sonos, Anslut (Ikea lights), Mi-Light etc etc etc etc. You can find a complete list of brands and devices on the Domoticz Wiki Page:
https://www.domoticz.com/wiki/Hardware
The Domoticz software is controlled from a webpage that can be accessed by your PC and there are Android App's available to control it from your tablet or phone.
You can even make rules like switch the TV on, close the curtains, switch the home-cinema on and dim the lights. So with one button your set for a move evening.
Summarising: with Domoticz you have a complete system to automate your home which will set you back around 60 euro.
I bought some cheap 433 Mhz switches and automated the lights in my hobby room, living room and with christmass I switch on the christmass-tree and all related lamps from anywhere with the App on my phone.
This is all great but I wanted more.
In all the years I am tinkering I build several projects with led-strips, sensors like a rain-sensor, door and window sensors, a thermometer etc. I want them all to be controlled from Domoticz.
Next to that I want to build some special switches. For example a switch with an LDR that tests the light in a room and automatically puts on the lamps when needed. Or a switch that puts a lamp on when someone enters a room. You can do all this with individual switches. But it is neat to have one central place where it all comes together.
As an add-on for Domoticz someone started a project called ESP-Easy ( https://www.letscontrolit.com/ ) that makes it easy to attach sensors to an ESP8266 and connect that to Domoticz. A really neat project so check it out.
However I want to do things myself and presumably you to otherwise you would stop reading from here.
So what I am going to show you here is how a button pressed on the ESP8266 sends a command to Domoticz which then sends a command to a 433Mhz light switch. Great for making remote controls for Domoticz. And next I am going to make a temperature sensor that sends it's data to Domoticz.
Intermezzo
I am moving away from ESP-Basic. It is no longer maintained nor updated. And there is no ESP32 version available. So I am building most of my new projects in the Arduino IDE (C++). I must admit that writing and develloping programs in ESP-Basic is faster as writing and debugging in C++. There are however a lot of nice sensors and add-ons available now which are not supported in ESP-Basic. So this story will be one of the last ones in which the program is in ESP-Basic.
ESP on screen button as remote for Domoticz
First thing we are going to build is an ESP8266 that creates a webpage on which a button can be clicked that sends information to Domoticz. In my setup I have a 433 Mhz lightswitch that controls a lamp in my hobbyroom which I am going to control this way.
Start with looking in Domoticz at the devices list for the switch you want to control. I wanted to control "Lucs room lampje" which has IDX number 3. We need that number to put in our program.
To control this switch we need to call a Domoticz API. You can find a list off all Domoticz API's here: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL's
On this page look for the entry : Turn a light/switch on
There you will find the required API call:
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=On
So what we need to do is to build a webpage with a button on it and when that button is pressed this code is send to Domoticz. And that is easily done with ESP-Basic.
For those of you who have no experience with ESP-Basic I urge you to read this tutorial which will have you up and running in no time:
http://lucstechblog.blogspot.nl/2017/03/back-to-basic-basic-language-on-esp8266.html
And here is the program.
cls
wprint |<h1 style="text-align:center;">Luc Volders</br>Domoticz</br>Control|
wprint "<br/><br/>"
button "Lamp on", [domoticzon]
wprint "<br/><br/>"
button "Lamp off", [domoticzoff]
wait
[domoticzon]
query = "192.168.1.66/json.htm?type=command&"
query = query & "param=switchlight&idx=3&switchcmd=On"
ret = wget(query,8080)
wait
[domoticzoff]
query = "192.168.1.66/json.htm?type=command&"
query = query & "param=switchlight&idx=3&switchcmd=Off"
ret = wget(query,8080)
wait
Let's have a look at this.
The program starts with putting some text on the screen and two buttons for ON and OFF.
When one of the buttons is pressed the program jumps to the accompanying routine wich calls the API. As described above the API looks like this:
/json.htm?type=command¶m=switchlight&idx=99&switchcmd=On
and that is translated in ESP-Basic in this:
query = "192.168.1.66/json.htm?type=command&"
query = query & "param=switchlight&idx=3&switchcmd=On"
ret = wget(query,8080)
query is the variable in which the data is collected that is going to be send. 192.168.1.66 is the IP number of my Domoticz setup. You have to replce that with your own IP. The rest of the API call is just copied except the IDX number which I altered in the number of my switch: 3
The wget statement sends the API call and puts the answer in the ret variable. You do not need to add this line but if you do not any info that Domoticz send back is displayed on the screen which makes a mess of your screen.
I do not think that it can be programmed in any other language for the ESP more easier.
And this is the result on your computer / phone / tablet's screen.
The buttons Lamp on and Lamp off switches lucs room lampje on or of and that can bee seen in Domoticz and off course by just looking at the lamp.
Temperature Sensor
I also wanted to send some sensor data to Domoticz. So I attached a Dallas DS18B20 temperature sensor to the ESP8266 (NodeMCU board) to see if I could get some readings.
To setup a switch or sensor in Domotics that is not physical attached but gets it's data through wifi you will have to define a virtual switch.
First in Domoticz open the devices tab and create a virtual switch. Give it a name. I choose Virtueel 3 and choose as type Dummy.
Now choose create virtual sensor I gave it as name Test temperature and as sensor type Temperature
At this moment the sensor is already visible in the Temperature Tab of Domoticz although it does not have received any value and therefore the temperature will be 0
Go back to the devices menu (Apparaten in Dutch) and there you can find Virtueel 3 and as you can see that the ID number is 4592
Next step is to build the hardware
My test setup is just a DS18B20 with a pull-up resistor of 4.7K attached to GPIO2 (D4) of a NodeMCU board.
In ESP-Basic I wrote a small test pogram to see if the sensor worked.
cls wprint |<h1 style="text-align:center;">Luc Volders</br>Domoticz</br>Thermometer| wprint "<br/><br/>" wprint "The temperature is now "& temp(0) wait
Nothing special. The program just reads temp(0) which is the DS18b20 and puts the value on the screen.
Back to the Domoticz API page on the web: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s#Create_a_virtual_sensor
Here we can read how the API call looks for reading a sensor.
/json.htm?type=command¶m=udevice&idx=IDX&nvalue=0&svalue=TEMP
IDX = id of your device (This number can be found in the devices tab in the column "IDX")
TEMP = Temperature
So we just need to implement that in our ESP-Basic program. Here you go:
cls timer 1000 * 60 * 5, [domoticztemp] wprint |<h1 style="text-align:center;">Luc Volders</br>Domoticz</br>Thermometer| wprint "<br/><br/></h1>" wprint "The temperature is now " textbox temptest wait [domoticztemp] temptest = temp(0) temptest = (int(temptest * 10))/10 query = "192.168.1.66/json.htm?type=command&" query = query & "param=udevice&idx=4592&svalue=" & temptest ret = wget(query,8080) wait
Again very easy to implement.
A timer is setup that every 5 minutes calls the [domoticztemp] routine.
Timer 1000 * 60 * 5 = every 5 minutes
The formula is simple. ESP's timer works in miliseconds. So 1000 = 1 second (1000 miliseconds). 60 Seconds in a minute and that times 5 minutes.
Why the 5 minute routine ? Well Domoticz just displays the sensors reading once in the 5 minutes on it's screen.
And there you go: the temperature is displayed in Domoticz.
Last step: Combine button and Temperature
A NodeMCU or a Wemos D1 have many I/O ports. Why not use them ? So let's combine the button and the temperature programs and include a physical button as well.
Again the hardware setup is easy. I took the temperature setup and added a button that is connected with a pull-up resistor (10k) to D3 of the NodeMCU board.
cls wprint |<h1 style="text-align:center;">Luc Volders</br>Domoticz</br>Control<br> And Thermometer| wprint "<br/><br/>" but=0 button "Lamp on", [domoticzon] wprint "<br/><br/>" button "Lamp off", [domoticzoff] wprint "<br/><br/>" wprint "The temperature is now " textbox temptest interrupt d3, [change] timer 1000 * 60 * 5, [domoticztemp] wait [domoticzon] query = "192.168.1.66/json.htm?type=command&" query = query & "param=switchlight&idx=3&switchcmd=On" ret = wget(query,8080) wait [domoticzoff] query = "192.168.1.66/json.htm?type=command&" query = query & "param=switchlight&idx=3&switchcmd=Off" ret = wget(query,8080) wait [change] if but = 0 then query = "192.168.1.66/json.htm?type=command&" query = query & "param=switchlight&idx=3&switchcmd=On" ret = wget(query,8080) else query = "192.168.1.66/json.htm?type=command&" query = query & "param=switchlight&idx=3&switchcmd=Off" ret = wget(query,8080) endif but = 1 - but interrupt d3, [change] wait [domoticztemp] temptest = temp(0) temptest = (int(temptest * 10))/10 query = "192.168.1.66/json.htm?type=command&" query = query & "param=udevice&idx=4592&svalue=" & temptest ret = wget(query,8080) wait
No surprises in the software either. An interrupt tests wether the button has been pressed and jumps to the [change] routine.
but = 1 - but
This line toggles the but value between 0 and 1 for setting the switch ON or OFF.
The rest is the same as in the previous programs.
This is how it looks on the screen of your computer / phone / tablet.
Hey, what's that Luc's Room Temperatuur thing ???
Well remember my "Oh no, not another wifi thermometer." entry in this weblog. If not you can re-read that story here: http://lucstechblog.blogspot.nl/2017/11/oh-no-not-another-wifi-thermometer.html
As you might remember this thermometer not only set's its data on the screen of a webpage but it also sends it's data to Thingspeak. To refresh your memory you can re-read the weblog entry here:
http://lucstechblog.blogspot.nl/2017/11/thingspeak.html
Well that thermometer has been sending it's data also for a long time now to my Domoticz setup.
Here is the altered code for that Thermometer.
tel=0 Timer 5000, [start] wprint "<!DOCTYPE html>" wprint "<html> <body>" wprint |<body style="background-color:greenyellow;">| wprint |<H1><span style="color: red;">| wprint " A thermometer" wprint "</H1>" wprint "</span>" wprint |<H2><span style="color: blue;">| wprint "Temperature is now " textbox test a = "background-color:greenyellow;" a = a & "display:block;width:80px;" a = a & "border-style: hidden;" a = a & "font-size: 22px;" a = a & "font-weight: bold;" a = a & "color: fuchsia ;" cssid htmlid(), a wprint "</span>" wprint "</H2>" Wait [start] test = temp(0) test = ((int(test*10))/10) tel=tel+1 if tel = 360 then tel = 0 gosub [thing] endif wait [thing] sendthing = str(test) SENDTS("MY-API-KEY", "1", sendthing) 'and to Domoticz domoticz = "192.168.1.66 /json.htm?type=command¶m=udevice&idx=2662&svalue=" & test wget(domoticz,8080) wait
As you can see the temperature is not only put on a webpage accessible from your computer/phone/tablet but also send to Thingspeak like described in this story:
http://lucstechblog.blogspot.nl/2017/11/thingspeak.html
And now it also sends the data to Domoticz, using the same code as described above with just another IDX.
The chart shows you that the thermometer has been working continuously from july 2017. This shows how reliable the ESP8266 and ESP-Basic is.
As stated in the beginning of this story: I am moving away from ESP-Basic to the Arduino IDE (C++). So in upcoming stories I'll be showing you how to achieve this in C++. So stay tuned.
Till then
have fun
Luc Volders
Labels:
433 Mhz,
Domotics,
ESP-01,
ESP8266,
ESP8266-Basic,
IOT,
NodeMCU,
Raspberry Pi
Subscribe to:
Posts (Atom)