Showing posts with label Domotics. Show all posts
Showing posts with label Domotics. Show all posts

Friday, August 22, 2025

Dweet.cc with MicroPyton

For an index to all my stories click this text

After my story about Dweet.cc and Freeboard I got some mails from readers of that wanted to know how to send data to Dweet.cc and retrieve data from Dweet.cc with MicroPython.

Well here we go.

Sending a dweet to Dweet.cc


The API call I used to send a temperature value to Dweet.cc with the thingname lucstechblog is as follows:

https://dweet.cc/dweet/for/lucstechblog?temperature=25

To use that API call in a MicroPython program you can use the following code:

import network
import urequests
# Router credentials
ssid = "YOUR_ROUTER_NAME"
pw = "PASSWORD"
print("Connecting to wifi...")
# wifi connection
wifi = network.WLAN(network.STA_IF) # station mode
wifi.active(True)
wifi.connect(ssid, pw)
# wait for connection
while not wifi.isconnected():
 pass
# wifi connected
print("Connected. IP: ",str(wifi.ifconfig()[0], "\n"))
# Replace 'lucstechblog' with your actual thing name
# Replace valuename with the name of the value you are sending
# Replace value with the actual value
thingname = 'lucstechblog'
valuename = 'temperature'
value = 25
value = str(value)
url = 'https://dweet.cc/dweet/for/'
url = url + thingname
url = url + "?"
url = url + valuename
url = url + "="
url = url + value
response = urequests.get(url)
print(response.text)
response.close()



That is it.

Put this code in Thonny and press the "run" button. And you will get the next response in the shell:



Of course your IP address will be different.
The response clearly states that the command had succeeded.

I will break the most important part of the code down here for you.

thingname = 'lucstechblog'
valuename = 'temperature'
value = 25
value = str(value)

These are the variables that need to be send to Dweet.cc

I used lucstechblog for the thing name but please use your own thing name. You can choose any name you want but best practice is to make it relevant.
Please be aware that we are sending a public dweet. So anybody in the world that sends a dweet with the same thing name will alter your value.

Then there is a valuename. I used temperature but use something significant like "kitchen-temperature" or "mancave-temperature". For a single dewwt this looks irrelevant but wait till you build a complete home automation system with this.

And then there is the value itself.
If the value is a number (integer or floating point) like in this example you need to convert it into a string like this example shows.

url = 'https://dweet.cc/dweet/for/'
url = url + thingname
url = url + "?"
url = url + valuename
url = url + "="
url = url + value

This is the code that combines all variables into the api call. Just make sure to incorporate the "?" after the thingname and the "=" after the valuename.

I split the code up like this so you can easily put this in your own program and replace the variable names into your own names.

Retrieving a value from Dweet.cc

The code for retrieving a value from the Dweet.cc server is:

https://dweet.cc/get/latest/dweet/for/my-thing-name

In this example it would be:

https://dweet.cc/get/latest/dweet/for/lucstechblog

Let's translate this in a MicroPython program.

import network
import urequests
import ujson
# Router credentials
ssid = "YOUR_ROUTER_NAME"
pw = "PASSWORD"
print("Connecting to wifi...")
# wifi connection
wifi = network.WLAN(network.STA_IF) # station mode
wifi.active(True)
wifi.connect(ssid, pw)
# wait for connection
while not wifi.isconnected():
 pass
# wifi connected
print("Connected. IP: ",str(wifi.ifconfig()[0], "\n"))
# Replace 'my-thing-name' with your actual thing name
thing_name = 'lucstechblog'
url = 'https://dweet.cc/get/latest/dweet/for/'
url = url + thing_name
response = urequests.get(url)
print(response.text)
response.close()

And here is the important part for this program:

url = 'https://dweet.cc/get/latest/dweet/for/'
url = url + thing_name

I splitted the api call in two parts. The first part is the general part and the second part adds your thingname. That is the variable you just created.

And this would gain the following response:




So this proves that it worked.

Decoding the JSON response.

So now we know that this works. However the response is JSON code. And unfortunately that is not direct usable in our program.

Suppose you want to display the temperature on an oled screen, or build a physical thermometer pointer with a servo, or use a bunch of neopixels to display the value like an old-school thermometer.
The JSON code would certainly not be suitable as a value we can work with. We have to decode it.

Here is the complete program that rertrieves the dweet and extracts the value.

import time
import network
import urequests
import ujson
# Router credentials
ssid = "Ziggo2903181"
pw = "ptzbB2ohKbgs7agp"
print("Connecting to wifi...")
# wifi connection
wifi = network.WLAN(network.STA_IF) # station mode
wifi.active(True)
wifi.connect(ssid, pw)
# wait for connection
while not wifi.isconnected():
 pass
# wifi connected
print("Connected. IP: ",str(wifi.ifconfig()[0], "\n"))
# Replace 'my-thing-name' with your actual thing name
thing_name = 'lucstechblog'
#url = 'http://192.168.178.62:8000/get/latest/dweet/for/Kit-pow'
#url = 'http://dweet.me:3333/get/latest/yoink/from/Man-temp'
url = 'https://dweet.cc/get/latest/dweet/for/'
url = url + thing_name
response = urequests.get(url)
print(response.text)
print ("============================================")
# Parse the JSON string
data = ujson.loads(response.text)
# Extract the temperature value
tempvalue = data["with"][0]["content"]["temperature"]
# Display the result
print("Temperature is:", tempvalue)

The important parts are these:

data = ujson.loads(response.text)

We create a variable that decodes the JSON response in its individual parts

tempvalue = data["with"][0]["content"]["temperature"]

There we extract the temperature value and put it into the tempvalue variable.

print("Temperature is:", tempvalue)


And this is where we print the actual value in the shell.

If your JSON code looks different you can use a JSON decoder of which there are several on the internet.

Now the value is stored into the tempvalue variable we can use it for our project.

Decoding JSON structures is a bit puzzling.


Click here to buy my book on the Raspberry Pi Pico W

But then you could buy my book on MicroPython with the Raspberry Pi Pico W that explains it in detail and shows how to get help from a JSON decoder.


Till next time
Have fun

Luc Volders



Friday, August 15, 2025

Freeboard with Dweet.cc

For an index to all my stories click this text.

In a previous story I informed you (as if you did not know) that Dweet.io stopeed working. They suddenly ceased their service and left many users in the dark. Their IOT projects just stopped working. You can read that story here:
https://lucstechblog.blogspot.com/2025/08/dweet-is-dead-long-live-dweet.html


Dweet.io was a great free service and what's more there was a good looking free to use dashboard available. It is called Freeboard and I wrote a few stories about this:
- A first look at Freeboard
- Use Freeboard on Github
- Run your own Freeboard on a Raspberry Pi

And as Dweet.io is not working anymore would I wondered if it would be possible to use Freeboard with one of the rising alternative services.

Altering the Freeboard source code

As written in the story about Dweet.io shutting down, there is an alternative that uses almost the same API calls. The name is Dweet.cc. The only thing you have to do is to alter dweet.io into dweet.cc in your api calls and your ESP8266, ESP32 or Raspberry Pi Pico's can talk to Dweet.cc.


Freeboard has a special datasource accessible called Dweet.io and of course that does notwork anymore.

So I started with adjusting the Freeboard source code.

In the story Run your own Freeboard on a Raspberry Pi I showed how you can download Freeboard and install it on your own PC or a Raspberry Pi.
Freeboard is written in Javascript and that offers opportunities for altering the code.

So I started opening all the HTML, CSS and JSON files in a text editor. I searched for dweet.io and changed it in dweet.cc
Well that did not work. Hmm.

JSON

And then I realized that there was a Datasource with the name JSON.


So I started by sending a simple api call with my browser to Dweet.cc:

https://dweet.cc/dweet/for/lucstechblog?temperature=25

And that worked. I got this as a result:


Ok, that worked.
For retrieving dweets you need to use:

https://dweet.cc/get/latest/dweet/for/my-thing-name

And in this case I had to replace my-thing-name into lucstechblog.

For more information about this, open the index of this weblog and look for Dweet. There are detailed stories on how to use it.
For testing please use your own "thing" name.

So now I had to implement this in Freeboard.
It really is easy and I am going to show you how to get the value for the thing lucstechblog and the value for temp
erature. Again if you want to try this go ahead but please use your own thing name.

First step is to put the get API call into the JSON configuration menu.

When filled in press "SAVE"


Now choose ADD Pane and a smal window opens.


Press the + on the top right side of that window


A pop-up window shows in which you can choose what kind of widget you want. In this example choose Gauge.


In the menu fill the data in as shown.
Pressing the datasource test on the right side gives you the opportunity to walk through the JSON steps.
Press SAVE


And there it is, my simple dashboard with only a gauge.

Now you can add multiple widgets to get your own dashboard up and running with Dweet.cc

If you have any questions that you can not find in the stories on this weblog) do not hesitate to send me a mail.

Conclusion.

Getting Freeboard to work with Dweet.CC was easier than I thought.
Just one problem remains...........Dweet.cc is again a cloud service and I wonder how long before THEY cease operation.........

So my main goal is still to build my own Dweet server that I can run locally. And guess what: I already have that running. It runs on a humble Raspberry Pi3 with a USB stick for memory. The base code was written by a friend of me and I enhanced it with a real database and some other stuff.
I am testing it as we speak.

So keep tuned for further updates on building your own Dweet server. But for now can can get it running with Dweet.cc

Till next time.
Have fun !!

Luc Volders

Friday, August 8, 2025

Dweet is dead, long live dweet

For an index to all my stories click this text.

I fall for it every time, and this time I have had enough.
Read on if you want to know what this is about.

It started a few year ago.

First there was Blynk.I was using Blynk for several projects. You could use their free service on which you could use a limited amount of IOT devices. But you could also install your own Blynk server on a Raspberry Pi and then you could use unlimited devices. And suddenly they switched to Blynk 2. The free server was removed from Github and the accompaning App was removed from Android Play.
Blynk 2 had at that time just a very limited free use. So that was the end of it.

Then there was IFTTT. They suddenly stopped allowing users to use free webhooks. You needed a payed subscription for that. So for using IFTTT with your IOT projects you suddenly needed a payed subscription. So that was the end of it.

Appybuilder, which was an app-building system based on MIT's App Inventor ceased working some time ago.

And the list goes on and on. Several services start giving their customers free access and then suddenly become paid services or quit alltogether.

And now Dweet

I have made some projects with dweet.io and published several stories about this service on this weblog. If you have no clue about what Dweet is read this story first:
https://lucstechblog.blogspot.com/2019/05/dweet-volatile-iot-cloud-service.html

And just January this year they quit too.


This was the message they posted on Twitter (X).
And that really pisses me off as there were lots of users.
So all the projects you made with Dweet.io just stopped working.

And what's more: this also shuts Freeboard down.
For those in the dark: Freeboard is a free IOT dashboard that offers buttons, switches, gauges, leds etc, etc. etc. With this you can make your own IOT dashboard for free but....... it relys on Dweet.io

And to be frank I loved Dweet for being free and it's simplicity.

Dweet users to the rescue.

I was not the only one who was pissed for being disappointed for the umpteenth time.

A few clever users came to the rescue and started a free public Dweet server by themselves. But there is a catch.

dweet.cc
This is the best alternative for dweet.io They claim on their website that at the moment of this writing a total of 1127113 dweets have been send.
It is free and uses nearly the same API.
The catch is that you need to change dweet.io into dweet.cc in the API calls.

dweet.me

Another alternative for dweet.io Dweet.me started 15 March 2025 and claim that they already had more than 1 million dweets on April 24 2025.
On the positive side it is just as free as dweet.io was, and it even offers someting extra. Dweet.io saved the last 5 messages. Dweet.me saves the last 8 messages.
On the negative side the website mentiones it is rate limited, although it does not state what the maximum rate is. And the API calls are more deviant from the dweet.io ones.
This means that you need a bit more altering your projects code.

dweetr.io

This is the last alternative I found. At the moment of this writing the number of dweets used was 57. Not a lot really. And there is a catch. You can only have 2 "things" for free. If you need more you will need a pro subscription. On the positive side: the subscriptions are cheap 25USD for 25 things and 49USD for 50 things for a period of 5 year !!!
The dweetr.io API looks similar to the original dweet.io. You need to change dweet.io into dweetr.io in the API call.

The API calls

I am going to show you the basic API call to send a dweet for the original dweet.io and for the 3 alternatives. So you can see for yourself what changes are needed to use the service.

Send dweet with dweet.io
This will not work anymore, but for comparing purpose only.
https://dweet.io/dweet/for/my-thing-name?hello=world

Send a dweet with dweet.cc
https://dweet.cc/dweet/for/my-thing-name?hello=world

Send a dweet with dweet.me
https://dweet.me:3334/publish/yoink/for/my-thing-name?hello=world

Send a dweet with dweetr.io
http://dweetr.io/dweet/for/my-thing-name?hello=world

As you can see the changes are minimal. Nevertheless you need to alter all your original dweet.io projects.

Which one to choose.

Well that is a difficult question.
Both dweet.cc and dweet.me claim to already have processed more than a million dweets. So it looks like their servers are robust. Dweet.me mentions on their website that it is rate limited and I send them a mail about that. Next to that their API is a bit different so dweet.cc looks like the better choice.
The limitation of just 2 "things" for the free tier makes dweetr.io the least attractive choice.

Mail me if you want the sourcecode for micropython or Arduino code for dweet.cc if you do not get this working. And maybe I am going to do a story about this anyhow.

And Freeboard ?

Freeboard will not work with any of these alternatives right out of the box.
I am going to try to get it working again but that might take some time, if I get it to work at all.........

But I had enough !!!

That's what I wrote at the beginning of this story.
And I am really fed up with companies or private individuals that offer IOT services for free and after a while start charging for subscriptions or quit the service all together.

And like you have seen in this story. There are alternatives to Dweet.io and just like the original they are free to use. But how long will it take for the developer to get fed up with it and shuts the service down, or decides it costs too much bandwidth and needs to charge money for the service.

So what is the real alternative.
Well, to put up your own server at home using a cheap Raspberry Pi or a small (obsolete) PC. That is what I am researching now for my future IOT projects. A Raspberry Zero is quite capable running a dweet alike service and will set you back just a few dollar/euro. So that is a serious option.
I'll keep you up to date through this blog, so keep returning here.

Till next time,

Luc Volders

Friday, March 14, 2025

Speeding up Domoticz

For an index to all my stories click this text.

As you might know from previous stories on this weblog I have Domoticz installed as my home automation system. It was only getting slower and slower.

Now my idea was that the problem might lay in the fact that I was using a Raspberry Pi 2. And as I installed the latest updates, that could indeed slow down my system. So I considered upgrading to a Pi 3 or Pi 4.
And just for your information: If you want to install Domoticz you will need at least a Pi3 as previous versions are no longer able to install Domoticz.



Clicking on the Devices Tab in the settings menu stopped the complete system for several minutes.

Then I noticed something.



Each page of the devices pages contains 100 entries (you can select that). And I had no less then 225 pages. That means that the database had 22500 entries.



And many of these entries were from years ago. As you can see the highest page numbers pointed to database entries from 2016. That is 7 year ago, at the time of this writing !!!

Why on earth would I want to keep that information. More even while the entries hold info on switches, thermometers etc from neighbours. And that that does not interest me.



So at the top of the page I clicked on the button that says Ongebruikt. The English version will mention Unused.

Next I clicked on the small V at the top. After two clicks all entries on that page were selected. Then I clicked on the waste basket next to the V and the entries from that page disappeared.

Make sure you use the Unused entries button otherwise you might remove your own settings !!!!

I removed all unused entries that way and this made Domoticz fast again !!!
So no need to switch to a more modern Raspberry Pi or even another home automation system !!!

Please be aware that Domotics keeps receiving and storing data from all kinds of switches and thermometers all the time. So a regular cleanup is advised.

Maybe it's me, but I could not find this simple speed improvement in the manual, so I did not want to keep it from you.

Till next time
have fun


Luc Volders





Friday, February 2, 2024

ESPEAsy part 5: ESPEasy to Telegram

For an index to all my stories click this text

After my previous stories on ESPEasy I received a few mails from readers that wanted to know if it is possible to send data direct from ESPEasy to Telegram. The advantage in that is that you can send alarm notifications direct to your phone.

If you do not know what ESPEasy is I urge to at least read my introduction tutorial and the tutorial about communication between two ESP's with ESPEasy. You will be amazed about the amount of features and drivers for sensors are crammed in this alternative operating system for the ESP8266 and ESP32. You can find these stories here:
http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html

http://lucstechblog.blogspot.com/2023/12/espeasy-part2-send-data-from-esp-to-esp.html

I also did a story on how to send data from ESPEasy to WhatsApp.
http://lucstechblog.blogspot.com/2024/01/espeasy-part-4-espeasy-send-data-to.html

Some readers pointed out to me that sending data from ESPEasy to Telegram should be easier as Telegram can communicate through a Bot. Well actually that is true and also not true.
Indeed Telegram can communicate through a Bot however that communication is done over HTTPS (secure HTTP) and ESPEasy does not (yet ???) support HTTPS.
The ESPEasy developers have stated that HTTPS communication requires a lot of memory and memory is scarce in ESPEasy as it is already crammed with features.

So as HTTPS communication is (as for now) out of the question rests just one other option at this moment and that is sending data to Telegram using the CallMeBot service.

CallMeBot

CallMeBot is a free service that is especially created to have electronic devices like the ESP8266 and ESP32 or programs send messages to WhatsApp, Telegram, Signal and Facebook. You can find it's website here: https://www.callmebot.com

We have to use the CallMeBot API to send messages from ESPEasy to CallMeBot. In a previous story I showed how to send data from an ESP8266 to WhatsApp and that explained how this works. Please re-read this story before you go on. You can re-read it here: http://lucstechblog.blogspot.com/2021/05/esp8266-and-esp32-sending-messages-to.html

That story showed that to send a message to WhatsApp through CallMeBot we have to use the following format:
http://api.callmebot.com/whatsapp.php?phone=+XXXXXXXXXXXX&text=This+is+a+test&apikey=YYYYYY

For Telegram there is a similar command:

https://api.callmebot.com/text.php?user=@myusername&text=This+is+a+test+from+CallMeBot

You can see the difference. CallMeBot does not sends the message to a Phone number but to your username. So start with setting your username in Telegram if you have not done so yet.



On your phone in the main Telegram menu click the hamburger icon at the top left of your screen. And then click General Settings.



Look at your profile settings and give yourself a username. Choose it carefully as all your contacts can use this username to send messages to you.

When done open your webbrowser to the CallMeBot webpage: https://www.callmebot.com/



Choose in the drop down menu Send Text Messages.



On this page you will find the explanation on how to use this service. And you can see the api call you need to use to send data to Telegram. As shown before in this text the api call looks like this:

https://api.callmebot.com/text.php?user=@myusername&text=This+is+a+test+from+CallMeBot

There is a green button on the page that says "Try to Send a test message now!" Click that button.



Fill in your username and your Text Message to Send and at the bottom you can see what URL you need to use to send the message.


Before the message is send a new screen opens which asks for a confirmation and Authentication. Press the green button and the message will be send to Telegram on your phone.



A confirmation message will be send to your phone. The above message is in Dutch as my phone is set into Dutch.



Now lets try a test message. Send the text First test.



And if all went well the message will appear in Telegram on your phone.

Breadboard


For this simple test we will only use a switch connected to D5 on our Wemos D1 Mini.

ESPEasy device setup.

I Will not go into all the details about installing the software on your ESP8266. That has been covered before on this weblog. Please re-read the stories in the following links for that:
http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html

To use the button on the breadboard got to the devices tab. Press Add and choose an input switch as the device. This also has been covered in the pre-mentioned stories. So re-read those for the details.



First let's have a look at the upper part of the devices screen.

The switch is called sw1 and it is enabled. We use the internal pull-up resistor of the Wemos D1 so check this button. The button on the breadboard has been attached to D5 which is GP14. The type is a switch and it is active when pressed so Push Button Active Low.



At the bottom make sure that Send to Controller 1 is checked and rename the variable (Values) to sw1val

ESPEasy Controller setup

The controller is a software driver that actually sends the data to another device or webservice. This is explained in the before mentioned previous stories so please re-read those for detailed information.

So switch over to the Controller Tab and Add a new Controller. As we are going to send over HTTP choose Generic HTTP as the protocol.



To locate the controller we do not use the IP adress but Use Hostname. And the Controller Hostname is api.callmebot.com
As we are sending data over HTTP the port number is 80.

We are sending data and commands to a service outside our own network so it might take a second or two to get a confirmation or acknowledgement. Therefore set the Client Timeout to 1000 ms (1 second)

The only thing left to do is to set the text we are going to publish. We have seen that the general command is:
https://api.callmebot.com/text.php?user=@myusername&text=This+is+a+test+from+CallMeBot
The hostname already has been set so we need to edit the text:
text.php?user=@myusername&text=This+is+a+test+from+CallMeBot

Replace user=@myusername with the username you have chosen for yourself.

The text we are going to send is an indication of what the data is and the data itself. The indication is simply button= and the data from the button is found in sw1#sw1val.
So the complete call will be:

text.php?user=@myusername&text=button+=+[sw1#sw1val]

Make sure to have enabled checked otherwise the Controller is not activated and then chose Submit.

Done !!!

Press the button attached to the ESP8266 and



There you are. We just send some messages to Telegram from ESPEasy.

You can have multiple data in one command and put each of them on a new line using %0A. Here is an example that would send the data from two buttons:

text.php?user=@myusername&text=button+=+[sw1#sw1val]+%0A+button2+=+[sw2#sw2val]



And here is the result.

That's it for now. Till next time
Have fun.

Luc Volders

Friday, January 19, 2024

ESPEasy part 4: ESPEasy send data to Whatsapp

For an index to all my stories click this text.

In this tutorial I am using an ESP8266 with ESPEasy installed. A button is connected to the ESP8266. When you press the button ESPEasy will send a message to Whatsapp. This is an example to show how we can send alerts direct from ESPEasy to our phone.

Introduction

ESPEasy is a kind of operating system for the ESP8266 and the ESP32 that has a good looking webpage and build-in drivers for hundreds of sensors and actuators. Even better: most of them are usable without you having to write 1 line of program code.
ESPEasy can send data to your home Automation system (like Domoticz or Home Assistant) but also to cloud services like Thingspeak and Freeboard. ESPEasy can even send data from one ESP8266 to another.
I wrote a series of articles on ESPEasy. Here is the list.

1) Getting started with ESPEasy
http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html

2) ESPEasy inter communication. Sending data from one ESP to another
http://lucstechblog.blogspot.com/2023/12/espeasy-part2-send-data-from-esp-to-esp.html

3) ESPEasy sending to and receiving data from Freeboard.
http://lucstechblog.blogspot.com/2024/01/espeasy-part-3-freeboard-iot-dashboard.html

What if you want a project to send it's data direct to your phone. ESPEasy can send data to your home automation system and that can send a notification to your phone. However ESPEasy can not send itself a notification to your phone. So what if you need a quick solution for a doorbell, rain detector, an alarm if your printer filament is broken, if someone opens the cookie jar etc. etc.

Here is a solution to that problem.

There is a service called CallMeBot. I have covered that here before as a means to send a message from an ESP8266 or ESP32 to WhatsApp. These work flawless but require you to program the ESP in C++. ESPEasy can do this without programming.

For this project you'll need an ESP8266 (I use the Wemos D1 version) and a button. And you will need to have that ESP8266 installed with ESPEasy. For installing ESPEasy read the first story in this series:
http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html

Next you need to have CallMeBot activated. You can read how to do that here:
http://lucstechblog.blogspot.com/2021/05/esp8266-and-esp32-sending-messages-to.html

The breadboard setup

As easy as it gets.



Just an Wemos D1 mini with a button attached to pin D5.

Setting up a switch.

Before we can use the button we need to setup a switch in ESPEasy.



Start at the Devices section. Press Add at task number 1.



Then click on - None - in the drop down menu and scroll down till you see Switch Input - Switch and click on that. Next fill in the settings for that switch.



In the top part of the settings page give the switch the name sw1 and make sure Enabled is checked.
We use the internal pull-up resistor in the ESP8266 so make sure to check that.
The switch is on the breadboard attached to D5 which is GPIO-14.
Choose switch as the type and Push Button Active Low.
This is because the switch is normally high (by the internal pull-up) and when pressed becomes low.
Leave the rest of the settings in this part as they are, and scroll down.



At the bottom of the page make sure Send to Controller 1 is checked. This attaches the switch to the first controller which is the part that actually sends the data to Dweet. And lastly rename the Value in sw1val. Then make sure to press Submit and the settings are stored in ESPEasy.

The referral to the switch in ESPEasy is Name#Value which is now sw1#sw1val. That is what we are going to use in the Controller part.

Setting up the Controller.

To send data from ESPEasy to another ESP or a Home Automation system or any other device you need to configure a so called Controller.



In this example the ESP8266 is only sending data to WhatsApp so we configure Controller 1. Click on the blue Add button at Controller 1.



The standard Controller Protocol is - Standalone. Click on that because we want to choose another option.



Choose Genric HTTP cause we are going to send an HTTP command to CallMeBot.

We have to use the CallMeBot API to send messages from ESPEasy to CallMeBot. Please re-read my story on CallMeBot that explain this. You can re-read it here: http://lucstechblog.blogspot.com/2021/05/esp8266-and-esp32-sending-messages-to.html

That story told us that to send a message to CallMeBot we have to use the following format:
http://api.callmebot.com/whatsapp.php?phone=+XXXXXXXXXXXX&text=This+is+a+test&apikey=YYYYYY

Of Course you will have to replace the XXXXXXXXX by your mobile phone number and the YYYYY by the CallMeBot api-key.

And we do not want to send the message: This is a test. What we want is to send the state of our button: 0 or 1. For example: Button value = 1.
The switch defined in the Devices section has the name sw1 and its value is in the variable sw1val.
Therefore we have tp replace - This is a test - by Button+value+=+[sw1#sw1val]
To put a variable into an equation or a text you need to put the full name of the variable between square brackets.

This makes our HTTP command complete:
http://api.callmebot.com/whatsapp.php?phone=+XXXXXXXXXXXX&text=Button+value+=+[sw1#sw1val]&apikey=YYYYYY



And here is how the complete settings for the Controller look.

The Protocol is Generic HTTP.
The Controller is Located by Using the Hostname
The Hostname is api.callmebot.com and as we are sending over http the Controller Port is 80.

The rest of the settings are good as the are except:

Client Timeout: 1000

The Client Timeout is the time ESPEasy should wait before it decides that there is no connection with CallmeBot. Within our own network a setting of 500 (half a second) is more then sufficient. But here we have to wait for a response over the internet. And when it is busy that will take a while. So start with setting this value to 1000 and do some experiments with a longer and shorter time.

And lastly we need to fill in the settings for Controller Publish; whatsapp.php?phone=+XXXXXXXXXXXX&text=Button+value+=+[sw1#sw1val]&apikey=YYYYYY

Again: do not forget to replace the x's with your phone number and the y's with your own CallMeBot api key.



And here are the messages in Whatsapp.

We've Dunnit !!!!!

This is the way to send messages directly from ESPEasy to Whatsapp.

Please be aware that CallMeBot has a limit of 25 messages per 240 minutes. That is about 1 message every 10 minutes. So pack more information in each message or limit the amount of messages you are going to send.



If there is for example a second button with the name sw2 and its variable is sw2val then you could send:

text=Button+value+=+[sw1#sw1val]+\n+button2+value+=+[sw2#sw2val]

The \n puts the information from the second button on a new line.The + sign puts a space between the words.

Have fun with ESPEasy
and till next time.

Luc Volders












Friday, January 5, 2024

ESPEasy part 3: Freeboard an IOT dashboard with ESPEasy

For an index to all my stories click this text.

Remember Freeboard ?? I wrote a story on Freeboard in October 2019. You can find it here: http://lucstechblog.blogspot.com/2019/10/freeboard.html

For those in the blind: Freeboard is an IOT dashboard that uses a service called Dweet to communicate with IOT devices. Freeboard is relatively easy to use and free of charge. Oh, yes, the original version of Freeboard is no longer free of charge. But luckily for us Freeboard can be forked from Github and you can then run your own Freeboard for........indeed free. Please read the above story for a tutorial on how to use Freeboard.

And lately I have published a few tutorials on ESPEasy. ESPEasy is a software package for the ESP8266 and ESP32. It is a stand alone solution for working with sensors and sending their data to a Home Automation system like Domoticz. ESPEasy has a good looking web-interface and has support for tons of sensors build in. You can also use ESPEasy to send information between multiple ESP's without the use of a dedicated server or cloud service. Just direct communication between two (or more) ESP's. And best of all: most ESPEasyfunctions can be used without 1 line of programming !! ESPEasy is certainly worth checking out. You can read my previous stories on ESPEasy here:
http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html
http://lucstechblog.blogspot.com/2023/12/espeasy-part2-send-data-from-esp-to-esp.html

Not all of the readers of this weblog have a dedicated Home Automation System like Domoticz. So I am going to show you how to use Freeboard as a dedicated IOT Dashboard for ESPEasy.

IF you do not have your own Freeboard up and running you can use freely my personal version which can be found here: http://lucsfreeboard2.000webhostapp.com/

Please make sure that you use http instead of https otherwise Freeboard does not work.

I did a complete series on Freeboard and you can find links to those stories on this page: http://lucstechblog.blogspot.com/2023/09/freeboard-revisited-5-install-add-ons.html

Dweet

As you might know from my previous story on Freeboard, Freeboard relies heavily on a service called Dweet to get its data from. So the way to send data to Freeboard is to send data to Dweet and Freeboard collects it from there.

In 2019 I wrote a complete tutorial on Dweet and you can re-read that here: https://lucstechblog.blogspot.com/2019/05/dweet-volatile-iot-cloud-service.html

Dweet itself can be found here: https://dweet.io/

Basically there are two important things to know about Dweet. The first is how to send data to Dweet and the second is how to retrieve data from Dweet. For working with Freeboard we only need to know how to send data to Dweet as Freeboard collects it automatically.

To send data to Dweet you need to send an HTTP command that looks like this:
http://dweet.io/dweet/for/my-thing-name?hello=world

In this my-thing-name is the name you want to give your sensor and hello is the variable name used with that sensor and in this example world is the data.
Before we are putting this into ESPEasy let's first look at the breadboard setup.

Breadboard

As we are going to send data from ESPEasy to Freeboard we need a switch that we can press, that Freeboard will be able to registrate. Next to that we are going to send a command from Freeboard to ESPEasy to set a led on.



The breadboard setup is the same as from my first story on ESPEasy. A button is attached to D7 and a led with a current delimiting resistor to D5.

ESPEasy to Freeboard

The first step is to install ESPEasy on your ESP8266. You can read how to do that in the first story on ESPEasy which you can re-read here http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html
Please also re-read the second story on ESPEasy in which Controllers and Devices are explained which we are ging to use here.

To send data from ESPEasy to another ESP or a Home Automation system or any other device you need to configure a so called Controller. In this example the ESP8266 is only sending data to Freeboard so we configure Controller 1.



As said before we are not sending data directly to Freeboard. We are sending data to Dweet and Freeboard will collect and display that data.

As Protocol to send data to Dweet we are using Generic HTTP.
The URL of Dweet (Locate Controller) is not the IP-Adress but Dweet's http name being dweet.io.
As the commands are send over http the port number is 80.

One very important setting is Client Timeout. This is the amount of time ESPEasy waits to get a reply from Dweet. This value is normally set to 100. That is ok when you are sending data to another ESP in your own network. Now we are sending data to a cloud service and a busy one !!! So give ESPEasy some time to wait for the answer from Dweet. Set the value for Client Timeout to 1000 or even 2000. Just test what will work for your situation.

And then another important setting is the Controller Publish setting. Here we have to fill in what we are going to send to Dweet.io.

Thye command to send data to Dweet is:
http://dweet.io/dweet/for/my-thing-name?hello=world

The first part (the Controller Hostname) is already filled in.

I am using espeasy as my-thing-name and testval as the name of the variable.

As I expect quite a few readers to follow this tutorial I kindly ask you to use a different name as espeasy. If everyone is using the same my-thing-name your results will become unpredictable. So replace espeasy with something like your initials and and the date. Be creative.

In the next section we are going to set a device (in the Devices setting) and that is going to be the switch. The switch will be named sw1 and the variable attached to it will get the name sw1val.

So what we are going to have the controller send is:

dweet/for/espeasy?testval=[sw1#sw1val]

Fill this in at the Controller Publish field.
Last step is to check the Enabled field and then press Submit.

On to the Devices section.



First press Add at task number 1. Then click on - None - in the drop down menu and scroll down till you see Switch Input - Switch and click on that. Next fill in the settings for that switch.



In the top part of the settings page give the switch the name sw1 and make sure Enabled is checked.
We use the internal pull-up resistor in the ESP8266 so make sure to check that.
The switch is on the breadboard attached to D5 which is GPIO-14.
Choose switch as the type and Push Button Active Low.
This is because the switch is normally high (by the internal pull-up) and when pressed becomes low.
Leave the rest of the settings in this part as they are, and scroll down.



At the bottom of the page make sure Send to Controller 1 is checked. This attaches the switch to the first controller which is the part that actually sends the data to Dweet. And lastly rename the Value in sw1val. Then make sure to press Submit and the settings are stored in ESPEasy.

As you can see the referral to the switch is Name#Value which is here sw1#sw1val and that is what we used in the controller part as discussed previous.

Back to Dweet.

Press the button on the breadboard. ESPEasy will now send its data to Dweet. And we can check that.

Open a fresh browser window or tab and fill in: http://dweet.io/get/latest/dweet/for/espeasy



And this is the result you should see. This makes sure that ESPEasy is indeed communicating with Dweet.

Getting the data in Freeboard

Open freeboard in a new browser tab or window. As stated before, if you do not have installed freeboard on your own webserver you can use mine: http://lucsfreeboard2.000webhostapp.com/

First thing to do is to tell Freeboard where the data is coming from.



At the right side on the screen choose ADD (below DATASOURCES).



Click on Dweet.io



As the to be displayed name I choose ESPEasy Test and the thingname of course is espeasy.
Make sure to fill in the name you gave my-thing-name in Dweet.



At the right top side of the screen you will see that the Datasource for ESPEasy Test is immediately updated.



At the left side on the screen now choose ADD PANE. And click on the + sign.



Click on Select a type and choose Indicator Light



Click on + Datasource and then click on the Datasource. At this moment there is only one and that is ESPEasy Test.



Then click on testval as this is the variable we need.



You can give the On and OFF text a name of your liking. I just simpl,y choose ON and OFF.
As the last step click on SAVE and your done.



Now press the button on your ESP and the led on your freeboard will go ON or OFF.

That's it. This is how you send data from ESPEasy to your Freeboard dashboard.


Freeboard to ESPEasy

We can receive data from ESPEasy and display that on Freeboard. But what about the other way round.
The breadboard has a led and we want to control that from our Freeboard dashboard. Well that can easily be done.

Start with clicking on the left side of the screen on ADD PANE

In the new PANE click on the + sign and then click on Select a type... This time we are going to add a switch.

First we start with giving the widget a name. I choose ESP8266's led as that is what it is.

ESPEasy has internal commands to set a GPIO pin on or off.
The General command is http://URL-ESPEASY/control?cmd=GPIO,number,1 or 0

We know the IP adress of our ESP8266 and that is 192.168.1.82
We also know that the led is attached to GPIO 13

Therefore the command for setting the led on is:
http://192.168.1.82/control?cmd=GPIO,13,1

Setting the led off is doen with:
http://192.168.1.82/control?cmd=GPIO,13,0

You can give the ON and OFF TEXT a name as I did. I simply choose ON and OFF. Alter this to your own liking. And SAVE.

Confused ??? Then read the first and second story on ESPEasy where all these commands are explained. You can find them here:
http://lucstechblog.blogspot.com/2023/10/espeasy-part-1-iot-without-programming.html
http://lucstechblog.blogspot.com/2023/12/espeasy-part2-send-data-from-esp-to-esp.html



There is our widget completed.



Click on the button next to the text ESP8266's led and the led on the Freeboard widget will change from OFF to on. At the same time (well almost) the led on your ESP8266 wil go on or off.

Save it

Don't forget to choose SAVE FREEBOARD to save the Freeboard settings to your computer. SAVE is at the top left side of your Freeboard.
Freeboard itself does not saves the data so if you dont do it then next time you open the Freeboard website you will have to fill in the Datasources and build all widgets anew.

That's it

This is how we can send data from ESPEasy to Freeboard and commands from Freeboard to ESPEasy.

Replace the led by a relays, pump, motor or whatever and start building your IOT system with ESPEasy and Freeboard. ESPEasy supports hundreds of sensors and actuators right out of the box, no installing needed. And as you have seen: no programming needed.

Your freedom with ESPEasy is a bit restrained compared to building your own program in the Arduino IDE. That is compensated by the speed and ease with which you can realise a project. Together with Freeboard ESPEasy is a great way to quickly build an IOT project.

Till next time
Have fun

Luc Volders

Subscribe to: Comments (Atom)

AltStyle によって変換されたページ (->オリジナル) /