Friday, August 16, 2019

Fritzing using non-library parts

For an index to all my articles click this text

Fritzing is for me at this moment still the best program for aiding with my projects documentation. You will have seen a lot of breadboard designs and schematics made with Fritzing on this weblogt. I already gave you two valuable tips on Fritzing in previous articles.

The first one was that you could print your designs and overlay them one-on-one on your breadboard. You can re-read that story here: http://lucstechblog.blogspot.com/2019/01/fritzing-projects-duplicated-easy.html

The second tip showed how you could merge several fritzing designs in one. Great for using building blocks in your designs. Re-read that story here: http://lucstechblog.blogspot.com/2019/08/fritzing-merger-of-boards.html
For those who have never used Fritzing before I really recommend it. Check it out and use it to document all of your projects. Fritzing is free to use and can be downloaded here:
http://fritzing.org/home/

Fritzing Parts.

Fritzing is as said a great tool. Fritzing however depends on hobbyists like you and me to add parts to it's library. And new parts emerge every day. Next to that not all hobbyists who use Fritzing will use all the parts. So sometimes you will stumble upon a part you want to use which is not yet in Fritzing's library. What to do.

Well first there is the option of using Fritzing itself to design a new part. It involves tedious work in a drawing program (like Inkscape), being very accurate with measurements and have a great compassion for designing in general.

Not my cup of tea. Sorry. I would love to be patience enough to design new parts but I just cant bring myself to it.

So what to do.

Sometime ago I stumbled upon this 4 7-segment display which I wanted to use in a project. The item name was TM1637 and there was no Fritzing library part for it. However I wanted to document my project. So what to deo.

Well actually there is a way to get a picture of the part into Fritzing. It will not be in your parts library but you can use it anyway.




First start with taking a picture of the part.



Now clean it up. I use the Gimp for editing my photo's but you can use any photo manipulation program you like. When done save it as JPG.




Open Fritzing in Breadboard mode and go to the parts bin. Select the core parts.
And scroll down to the breadboard parts.


Select the last Icon. That is the icon for importing pictures. Drag it to your workspace.


Click on the icon on your workspace and look at the inspector. In the inspector select your picture.

Ok. Ok. from the above pictures you can see why I am not good at designing parts. Just look at those crummy arrows.......

The picture is loaded into your workspace. Scale it down to a usable scale.
Last step is to scale it to real-world measures. Best is done by orienting it to your breadboard so you can see the headers will fit the breadboard size.

That is it.
Now you can use the part like any other part from the fritzing library. There are however some restrictions.
- Every time you want to use the part you will have to load it again
- After loading you will have to resize it.
- No pinnumbers with descriptions will be shown
- The part is not up to real-life scale

I can live with these restrictions and just am glad I found a way to import non-library items.

Till next time
Have fun

Luc Volders

Friday, August 9, 2019

Dweet again

For an index to all of my stories click this text

As you will recall as a frequent reader of this weblog my previous story introduced Dweet. A kind of cloud-based IOT messaging system to which you can send data using an API call. Next you can retrieve that data with another API call. All data is send publicly (unless you use a paid account) and can be retrieved by anyone if they happen to know the credentials. You can re-read that story here:
https://lucstechblog.blogspot.com/2019/05/dweet-volatile-iot-cloud-service.html

Months ago I wrote a story on how I build a thermometer. I am no fan of YAT (yet another Thermometer) however they have one big advantage: they are a source for data that can be used for testing. So look at the schematics and build yourself a version.  You can find all details here: http://lucstechblog.blogspot.nl/2017/11/oh-no-not-another-wifi-thermometer.html

Next step was to send the data from the thermometer to thingspeak. Read that story here: http://lucstechblog.blogspot.nl/2017/11/thingspeak.html

And then some time ago I wrote a story on how you could use the ping command to check if someone was at home or if all your network devices were working properly. You can re-read that story here: https://lucstechblog.blogspot.com/2019/05/ping-ping-anybody-home.html

And now we are going to send all this information to Dweet.

And again for rapid prototyping and quick results I am going to use ESPBasic as the devellopment environment. Read all primary information about installing and using ESPBasic here: http://lucstechblog.blogspot.nl/2017/03/back-to-basic-basic-language-on-esp8266.html

Sending thermometer values to Dweet

For starters I urge you to re-read the story about the thermometer and study the program thoroughly. Re-read the story here:
http://lucstechblog.blogspot.nl/2017/11/thingspeak.html

From the Dweet story we remember that the general API call is:

http://dweet.io/dweet/for/my-thing-name?hello=world

Let's adapt that for sending the thermometer value with ESPBasic.

First have a look at the most important lines from the Basic program: the lines that actually get the temperature:
test = temp(0)
test = ((int(test*10))/10)


The lines above get the temperature from a to an ESP connected temperature sensor (DS18B20) and round that to 1 decimal.

Next step is to look at the example I used in the story about Dweet. I send a fake temperature using the following line:

https://dweet.io/dweet/for/Lucstemp2018?temp=25

So the complete Dweet API call for the thermometer value would be:

https://dweet.io/dweet/for/Lucstemp2018?temp=test

Let's adapt that to a real ESPBasic command:

tosend$ = "dweet.io/dweet/for/Lucstemp2018?temp="&str(test)
helper$= wget(tosend$,80)
helper$ = ""


As you know by now Dweet wil send information back in the form of JSON code when you send information to the service. That is why I used the lines:

helper$= wget(tosend$,80)
helper$ = ""


This way the information that is send back will not be displayed on the screen but captured in a variable which is cleared immediately afterwards so the memory will not be cluttered up.

So here is the complete Thermometer program that sends the temperature to a webpage, Thingspeak and as well as to Dweet:


 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]  
 ' send to Thingspeak  
 sendthing = str(test)  
 SENDTS("MP8Y1YLJUWZ4RTVR", "1", sendthing)  
   
 'send to Dweet  
 tosend$ = "dweet.io/dweet/for/Lucstemp2018?temp="&str(test)  
 helper$= wget(tosend$,80)  
 helper$ = ""  
 return  


I made some tests and then retrieved the data from Dweet.

The Dweet documentation discusses an API call to get the last send data. The call's general form is:

https://dweet.io/get/dweets/for/my-thing-name

Adapting that for my Themometer that would be:

https://dweet.io/get/dweets/for/Lucstemp2018

I just put that in my browser and here is the result:


Sending Ping information to Dweet.

One of the previous stories on this weblog featured a method to test wether someone was at home and test if your network attached devices were up and running. I urge you to re-read that story and examine the source code thoroughly as we are going to use that to send the network status and the information about who is home to Dweet. So first re-read the original story here:
https://lucstechblog.blogspot.com/2019/05/ping-ping-anybody-home.html


The web-page the ESP makes looks like the page above.
Again this is done in ESPBasic.

Let's examine the part in the code were the program tests wether I am home or not by Ping-ing my phone's IP-adress.

lucphone = ping("192.168.1.67")
if lucphone = 1 then
io(po,D2,1)
lucphone = "at home"
else
io(po,D2,0)
lucphone = "he's not in"
endif

Well that part is easy. If lucphone = 1 then I am in and else I am out.

If I am going to send this info to Dweet I need to send the variable lucphone to Dweet. However the variable is used in some text. And I just want to send the plain data being 0 or 1. Why ? Just keep following this weblog it'll be explained in an upcoming story.
To do that alter this part of the program as follows:

lucphone = ping("192.168.1.67")
lucphone2=lucphone
if lucphone = 1 then
io(po,D2,1)
lucphone = "at home"
else
io(po,D2,0)
lucphone = "he's not in"
endif

As you can see I preserved the value of lucphone in a new variable lucphone2. And that is what we can Dweet.

Maybe you recall from the Dweet story that every sensor is called a 'thing' and needs a name. As I am not using the Thermometer ESP for this, but a separate ESP I am going to give this ESP another name being Lucshome.

For just Dweeting my phone info the API call looks like this:

http://dweet.io/dweet/for/Lucshome?phone=lucphone2

Let's transorm this to proper ESPBasic code:

tosend$ = "http://dweet.io/dweet/for/Lucshome?phone="&str(lucphone2)
a$= wget(tosend$,80)

However we do want to send all the information from our Ping program. So we have to create extra variables for each test just like we did for lucphone. So add the proper lines in the program for therm2, domo2 and elsphone2.

And then we get the following complete program:


io(po,D0,0)
io(po,D1,0)
io(po,D2,0)
io(po,D4,0)

timer 1000, [testping]

wprint |<body style="background-color:powderblue;">|
wprint |<H1><span style="color: red;">|
wprint "Anybody Home ??"
wprint "</H1>"
wprint "<h3>Thermometer  "

textbox therm
cssid htmlid(), "background-color:powderblue;border-style: hidden;font-size: 16px;display:block;width:80px"

wprint "<br>"
wprint "Domoticz         "
textbox domo
cssid htmlid(), "background-color:powderblue;border-style: hidden;font-size: 16px;display:block;width:80px"

wprint "<br>"
wprint "Luc's phone      "
textbox lucphone
cssid htmlid(), "background-color:powderblue;border-style: hidden;font-size: 16px;display:block;width:80px"

wprint "<br>"
wprint "Els phone        "
textbox elsphone
cssid htmlid(), "background-color:powderblue;border-style: hidden;font-size: 16px;display:block;width:80px"

wprint "<br>"
button "QUIT", [progend]
wait

[testping]
therm = ping("192.168.1.65")
therm2=therm
if therm = 1 then
io(po,D0,1)
therm = "available"
else
io(po,D0,0)
therm = "off line"
endif


domo = ping("192.168.1.66")
domo2=domo
if domo = 1 then
io(po,D1,1)
domo = "available"
else
io(po,D1,0)
domo = "Domoticz off line"
endif

lucphone = ping("192.168.1.67")
lucphone2=lucphone
if lucphone = 1 then
io(po,D2,1)
lucphone = "at home"
else
io(po,D2,0)
lucphone = "he's not in"
endif

elsphone = ping("192.168.1.72")
elsphone2=elsphone
if elsphone = 1 then
io(po,D4,1)
elsphone = "available"
else
io(po,D4,0)
elsphone = "she's out"
endif

tosend$ = "dweet.io/dweet/for/Lucshome?therm="&str(therm2)&"&domo="&str(domo2)&"&lucphone="&str(lucphone2)&"&elsphone="&str(elsphone2)
a$= wget(tosend$,80)

wait

[progend]
io(po,D0,0)
io(po,D1,0)
io(po,D2,0)
io(po,D4,0)
end


And it works:




Caveats and pitfalls

I really enjoy playing with Dweet. However there are some serious caveats and pitfalls that you must consider.

Ever heard of number stations ?

These are radiofrequencies on which at certain times a day a list of numbers were send. It is a widely known phenomenon. Number stations were short wave transmissions alledgedly send to spies. Just Google "number stations" and a whole new world will open up to you. In the modern information age there are twitter accounts which are the equivalent of number stations. Look for example to these:
https://twitter.com/googuns_staging?lang=en
https://twitter.com/SierraGolf5
https://twitter.com/cynthiafortune
https://twitter.com/ZuluTango4
https://twitter.com/station_15a
https://twitter.com/ns111042

Well you can imagine that it is easy to use Dweet for sending secret information. Moreover since you can Dweet from a TOR browser so your IP adress can not be localised. Besides that the secret information can be disguised as genuine sensor readings. And after 24 hour the information is ereased !!! So nearly impossible to trace.

More down to earth.

In this story I Dweeted and used Lucstemp2018 and Lucshome as my 'things'.
Anybody reading this weblog knows that now. So anybody can put the following line in their browser and look at my data.

http://dweet.io/get/dweets/for/Lucstemp2018

Even worse. Anybody who has read this entry and the previous one can alter any Dweet they see at the Dweet webpage. So be carefull and responsible with this free service and do not spoil it for others.

Till next time
Have fun

Luc Volders

Saturday, August 3, 2019

Fritzing merger of boards

For a complete index of my stories click this text

As you will know I have written a book about the ESP32. It is in Dutch and undoubtedly you want to buy it for which you can find a link at the bottom of this page. In this book there are breadboard schematics which are designed with Fritzing. While using Fritzing extensively I stumbled upon a feature I did not know existed, and never have seen being used before.




I designed a small stripboard setup for neopixels which consist of some capacitors for stabilising the power supply and a resistor for attaching to the datalines. There is an USB connector on the board for supplying the power. You can read about this in my intro story about neopixels which you can re-read here: http://lucstechblog.blogspot.com/2015/10/neopixels-ws2812-intro.html



And I desgned a small stripboard for a DS18B20 thermometer chip.

Sidenote: thermometers are stupid. The internet of things is paved with thermometers and weather stations and I don't have a clue why everyone is building them. Presumably it's because they don't have anything better to make. Lack of creativity and fantasy. When I look outside my window I can see that it is raining or not and I can feel if it is cold or hot. I do not need a thermometer or weatherstation for that.
The only reason I think a thermometer is interesting is because it is a constant source of data which I can use for testing purposes.


So for the sake of this demonstration let us suppose that I am going to build a thermometer that displays the temperature on a strip of neopixels. Something like: below 20 degrees the pixels are blue and above the pixels are red.

What would I need.
Well a microcontroller like an Attiny85 or a Wemos D1
A Dallas DS18B20 thermometer chip with a pull-up resistor
A strip of neopixels.

Hey by coincedence I have designed two small stripboards with these items which I can use as a kind of building blocks. But they are all in separate Fritzing files.

Well here comes the trick.



First open Fritzing and start a new Breadboard setup. Put a Half breadboard on it and then put a Wemos D1 on that.



Open a new file. My version is in Dutch but just choose File and New.



In this new screem open the DS18B20 stripboard



Select the DS18B20 stripboard with all its components and just drag it onto the other window.
 





Do the same for the Neopixels stripboard



The last step is to select with your mouse one by one the stripboard with their parts and rotate them.
Now you only have to draw the wires and your project is complete.

I realise that in reality you (and I) work the other way round. First you build the project and then you make the Fritzing schematics. However Fritzing is great for documenting your projects like I am doing on this weblog.

I have used Fritzing for a long time now but never knew that it was so easy to bring parts from one design into another project. This works with stripboards and with breadbords. And it also works by choosing just parts of your design and transporing them to another board.

Till next time.
Keep experimenting you never know what you might find.

Luc Volders