Page 1 of 1

thinger IOT project

PostPosted: Sun Apr 23, 2017 12:09 am
by pretentious
For anyone interested in this area, I'm playing around with my own home IOT(internet of things) set up. I'm using as my server. Basically it allows you to hook up hardware to the main system via most networking methods and expose an arbitrary restful interface to the server using C/C++. Documentation seems pretty scarce but I've only gone in ankle deep. I've got 2 web servers running at my house at the moment, using raspberry pi's that I'm gonna hook up(raspberry toggle is feeding me light states every hour which I'm graphing woohoo :lol: (hopefully I can do alerts or something) and the other has a light sensor I can harvest data from) and I'm getting some blue tooth and wifi modules and relays which is where the real magic is gonna happen. I'll keep you guys posted 8-)

Re: thinger IOT project

PostPosted: Wed Apr 26, 2017 7:03 am
by boriz666
Hey pretentious ,
sick good to hear that you are tinkering with IOT stuff, its an amazing field
that i am quite into myself.

I use a rapberry pi as the main hub to get censor information from my other
home made devices through CAN bus, which i like a lot due to the robustness
of the protocol and hw.

I have started to make a LCARS gui in QT, on my main linux box, and the idea
is that it will interface with the raspberry pi (via http) and get the sensor data from there
and also it can send commands to the rpi, which lights it should turn on / off etc.

The server part on the rpi, i use a embedded webserver project called mongoose,
which i am pretty happy about, its been running for a year now without a problem.

All the sensors i make are homemade aswell as the control circuitry for the light
switches etc.

Will be loooking forward to progress updates on this, its very very interesting to
work with stuff like this, that can control the real world.

Re: thinger IOT project

PostPosted: Tue May 02, 2017 4:14 am
by pretentious
So I got a raspberry pi 3, which comes with bluetooth and wifi out of the box. It was pretty easy to install on a ubuntu machine but raspian was a massive headache. thinger uses snap which is a modern replacement for aptitude which I tried to get installed on my pi, and gave up. I ended up rage quitting after to days of tying and bought the raspberry pi image ... io-server/

I hooked up both of my raspberry pi web servers with thinger_client daemons and got some graphing going on ... g_1335.jpg
Something that I'm disappointed by(not a super big deal) is that documentation is pretty scarce/non existant it seems for linux clients. I mean embedded tutorials have you covered but I'd love to run background daemons on my local hosts and fire off emails and sms's when interesting things happen.

I got a WeMos D1 wifi enabled arduino compatible board from ebay which, with a bit of intitial set up got it connecting to my wifi
Super psyched about this. I was really surprised how easy it was. Just ran some example code and boom. ... g_1344.jpg

aaand about 3 seconds later, got it connected to my server and exposed a 'relay' interface and my relay is controllable ... g_1347.jpg

Next thing to do is to wire the relay into my desk lamp and control it via the arduino.(gonna buy some gear to make this not a fire hazard first)
boriz666 wrote:home made devices through CAN bus, which i like a lot due to the robustness
of the protocol and hw.

One of my colleagues suggested this :) , I'm gonna look into it, but I think most of this stuff is taken care of in my case
boriz666 wrote:All the sensors i make are homemade aswell as the control circuitry for the light
switches etc.

I envision myself making stuff internet ready by voltage dividing the cricuit to power my IC on the side and using the GPIO's to interface with the circuitry inside. Have you tried this? pros cons and pitfalls?
boriz666 wrote:Will be looking forward to progress updates on this, its very very interesting to
work with stuff like this, that can control the real world.

Right now, It's winter in Aus, so I'm getting a temperature/humidity sensor and will try and hack my room heater :P
I want to make my circuits as small as possible and glue them into the appliances that I hack but I've found that I'm probably gonna save time, money and effort to just use premade boards like the D1

Re: thinger IOT project

PostPosted: Wed May 03, 2017 3:59 am
by boriz666
I envision myself making stuff internet ready by voltage dividing the cricuit to power my IC on the side and using the GPIO's to interface with the circuitry inside. Have you tried this? pros cons and pitfalls?

I'd not recommend using a voltage divider circuit to power your ic, its not very stable
and its very load dependant on providing the correct voltage.

Instead use a voltage regulator like ... 22008E.pdf.

When interfacing with circuitry from your micro controller, always be sure that its logic level is the same
as your micro, a 3.3v micro will be fried if the thing you wanna controll is 5v logic level.

For working with 220v ac mains, i always buy some cheap relay boards on ebay, they are controllable directly
from a raspberry pi, or a microcontroller. ... SwX61ZB-Sr

I had a 8 channel relay board running for several years, controlled by a rpi, with no problem at all, just make
sure that you dont plug in more stuff than your fuse can handle. I am controlling mostly lamps with mine,
so its not even close.

I am soon going to make my newish microwave oven connected to the lan, via wifi, so it can be controlled
from the local lan, I think I am gonna make some kind of tutorial for it so people possible can learn
something about it.

The microwave has a lot of buttons, each of which need a gpio pin. I'd normaly use a ESP8266 wifi solution,
but I need more gpio pins, both for keys and to read the status of the microwave.
If its finished or not and idealy how much time is left.

So I'll make a combination of a PIC18F2480 and a ESP8266 wifi module, that way i can also make it CAN ready
cause the pic has a can controller build in.

Re: thinger IOT project

PostPosted: Tue May 16, 2017 9:16 pm
by pretentious
this project has been a little 1 step forward 2 steps back in the last few weeks.
I got my d1 to toggle a relay and turn my desk lamp on but got some strange issues when resetting the arduino.
I ran this by my embedded engineer colleague and he's like where is your flyback diode and I'm like, my flyback what? lol so it hasn't been quiet plug and play. My thinger server also crapped itself and wouldn't even boot at about the exact time i was looking for alternative iot solutions and found thingsboard, which has a lot more documentation and provides several networking standards built in(mqtt http) which means i can build custom apps which just need to send the right http messages and they can be part of my network. An issue I'm having with thingsboard is that its heavy. The instructions to install it on my pi are to cripple cassandra so that it doesn't turn my pi into a silicon puddle. I'm exaggerating lol but it does feel resource heavy, was build for aws after all i guess. So at this point I have a temperature/ humidity sensor that I'm trying to connect to my server. It gets an ip and pushes data at the server but I'm still working on the servers back end config

Re: thinger IOT project

PostPosted: Thu May 18, 2017 3:32 am
by boriz666
Greetings Sir,
I thought you was using a relay board like: ... d&_sacat=0

But it seems you are using your own relay, to control it.
Because there is a coil in the relay, when current flows a magnetic field is generated which
turns the relay on, thats good and dandy, but when the relay turns off the field collapses and
current stops flowing fast which means that the voltage will spike, and that can damage your

To "lead" the voltage spike away you place a diode across the coil of the relay as pr this ... and-relays, a single
diode is normaly sufficient.

Also, how do you turn on the relay? Do you use the microcontroller pin directly (which is not
preferred as turning on a relay takes a lot of current, compared to what a mcu can handle),
or do you use a mosfet?

I made a small schematic of how to connect and controll the relay.

The mosfet you wanna use is whats called a logic level mosfet, that is, its "opened" with a
low voltage,at around 3.3v.

Everything with an inductor in it should have a flyback diode in it, that is relays, motors,
actuators etc.

Re: thinger IOT project

PostPosted: Tue May 23, 2017 9:31 pm
by pretentious
Disregard my last post speculating about the circuitry of my relay. I'm using an srd-05vdc-sl-c like the ones you linked. These use 5v logic and my dev board has 3.3v gpios which i think caused unexpected results and i am way out of my depth, academically here, so i went down some weird rabbit hole lol. Ahh well, this is how mastery works, I'll buy 5 and break 4.
Making a mental note to update you guys with some progress and pics after work.

-- Sun May 28, 2017 12:57 pm --

Ok So I started this over a month ago. Had some really interesting POC's but also man into a bunch of hurdles haha.
The first major issue I had into was using NOOBS to run my pi. I would get the latest install and set it up. Everything would look stable and sexy, I would set up thingsboard and get telemetry data coming though and can graph it and it will all be super exciting because you can do anything, once you have data.
I have the temperature sensor working with my D1 but I'm gonna use a arduino nano/(or cheap chinese one) in the future because 3.3v logic isn't gonna cut it. I'm waiting on jumper leads from ebay to hook up my wifi modeule and relay
This was all fine and dandy for like 2 days, and then my pi will crap its pants with a kernal pannic
Code: Select all
unable to mount root fs on unknown-block(179 7)

I had limited time and access to a TV to troubleshoot the problem so it's taken me like a couple of weeks to get it sorted. I've bought a new sd card and flashed the full working raspian/pixel system onto my card but I'm still not holding my breath, If it breaks again in like 2 days, I'll try the boot/config.txt fix or rage quit and re-purpose an old laptop for this project. I wanted the pi for it's inbuilt networking features and low energy consumption but if it's not gonna work, it's not gonna work, Also I'm in a field where there is limited documentation so should be avoiding precarious ad hoc implementations if I can, I'm too busy for this crap.
I've also had issues with cassandra. I'm not 100% confident that if my pi reboots, cassandra and thingsboard will initialize properly. The thingsboard documentation reccomends limiting cassandras memory allocation and increasing timeouts ten fold. I'm not sure how I feel about this, it seems like a hack and another reason to commission my IOT project with a 3ghz CPU. With that said, many of my problems could be down to user error or race conditions that turned up because I was starting and stopping heavy services or something, so I'm reserving my judgment.

Now onto the good bits ;)
Thingsboard has a super simple device set up, and seems really extendable which I like a lot
All you need to do to specify a device is its access key and fire off a http post and you're good(anything with an ip can become a 'device' and sent or recieve information from my server :o :D ). I give my arduino the key and a static ip and it hooks up, thingsboard takes care of the rest.
This is the code for my temperature sensor
Code: Select all
#include "DHT.h"
#include <PubSubClient.h>
#include <ESP8266WiFi.h>

// the IP address for the shield:
IPAddress ip(192, 168, 0, 202);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);
#define WIFI_AP "noap"
#define WIFI_PASSWORD "Nooooaaaap"

#define TOKEN "anything you want"

// DHT
#define DHTPIN 2
#define DHTTYPE DHT11

char thingsboardServer[] = "";

WiFiClient wifiClient;

// Initialize DHT sensor.

PubSubClient client(wifiClient);

int status = WL_IDLE_STATUS;
unsigned long lastSend;

void setup()
  WiFi.config(ip, gateway, subnet);
  client.setServer( thingsboardServer, 1883 );
  lastSend = 0;

void loop()
  if ( !client.connected() ) {

  if ( millis() - lastSend > 60000 ) {
    lastSend = millis();


void getAndSendTemperatureAndHumidityData()
  Serial.println("Collecting temperature data.");

  // Reading temperature or humidity takes about 250 milliseconds!
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");

  Serial.print("Humidity: ");
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(" *C ");

  String temperature = String(t);
  String humidity = String(h);

  // Just debug messages
  Serial.print( "Sending temperature and humidity : [" );
  Serial.print( temperature ); Serial.print( "," );
  Serial.print( humidity );
  Serial.print( "]   -> " );

  // Prepare a JSON payload string
  String payload = "{";
  payload += "\"temperature\":"; payload += temperature; payload += ",";
  payload += "\"humidity\":"; payload += humidity;
  payload += "}";

  // Send payload
  char attributes[100];
  payload.toCharArray( attributes, 100 );
  client.publish( "v1/devices/me/telemetry", attributes );
  Serial.println( attributes );


void InitWiFi()
  Serial.println("Connecting to AP ...");
  // attempt to connect to WiFi network

  while (WiFi.status() != WL_CONNECTED) {
  Serial.println("Connected to AP");

void reconnect() {
  // Loop until we're reconnected
  while (!client.connected()) {
    status = WiFi.status();
    if ( status != WL_CONNECTED) {
      WiFi.begin(WIFI_AP, WIFI_PASSWORD);
      while (WiFi.status() != WL_CONNECTED) {
      Serial.println("Connected to AP");
    Serial.print("Connecting to Thingsboard node ...");
    // Attempt to connect (clientId, username, password)
    if ( client.connect("ESP8266 Device", TOKEN, NULL) ) {
      Serial.println( "[DONE]" );
    } else {
      Serial.print( "[FAILED] [ rc = " );
      Serial.print( client.state() );
      Serial.println( " : retrying in 5 seconds]" );
      // Wait 5 seconds before retrying
      delay( 5000 );

I stole most of this off the internet and it works like a charm. Been sitting in my room running off a usb charging port for the last 2 weeks, with a garbage bag over the leds lol, though half the time there wasn't a server for it to hit lol
Anyone who is into electronics at all, needs to get an arduino, the learning curve is virtually non existant if you have a dev background.

Right now my server is set up with a static wlan0 ip of, I'm reserving 201 for it's eth0 port if that comes up at some point, and I'm keeping my IOT devices in the 200 range. IPv4 is actually a super easy protocol but I'm also taking a look into bluetooth.
I don't think thingboard has bluetooth connections out of the box but I can easily run a service on my pi to translate connections for bluetooth devices. Here's a POC for my phone's bluetooth. I'm using it to tell my IOT server when I'm home or not, This will link in with my temperature sensor soon hopfully :)
Code: Select all
import time
import bluetooth
import os
while True:
  target_name = "pretentious's iPhone"
  target_address = None

  nearby_devices = bluetooth.discover_devices()

  for bdaddr in nearby_devices:
      print bluetooth.lookup_name( bdaddr)
      if target_name == bluetooth.lookup_name( bdaddr ):
          target_address = bdaddr

  if target_address is not None:
    print "found target bluetooth device with address ", target_address
    os.system('curl -v -X POST -d {"at_home":1} http://localhost:8080/api/v1/secretkey/telemetry --header "Content-Type:application/json"')
    print "could not find target bluetooth device nearby"
    os.system('curl -v -X POST -d {"at_home":0} http://localhost:8080/api/v1/secretkey/telemetry --header "Content-Type:application/json"')

Again this is all code that I've stolen from the internet, which basically worked out of the box, with little surprises along the way.

So at the moment I'm waiting for electronics in the mail and waiting to see if my server dies on my again, so no crazy new adventures for a little while but hypothetically, next thing is th hook up my lamp and toggle it with RPC's(probably integrate with the bluetooth beacon as well) and I want to control my tv using ir modules which I'll probably make IOT compatible as well(already have kodi set up but my speaker system requires a separate remote to turn it on, fuck that lol)

-- Tue May 30, 2017 8:42 pm --

So my bluetooth POC only really worked when my phone was looking for connections, seemed promising but it's not actually gonna work. Lucly for me tho, we live in a world where everything that has ever been thought of has been implemented in python so from
Code: Select all
import os
import bluetooth
import time

print "In/Out Board"
at_home = False
while True:
    print "Checking " + time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())

    result = bluetooth.lookup_name('XX:XX:XX:XX:XX:XX', timeout=5)
    if (result != None):
        at_home = True
        print "pretentious: in"
        os.system('curl -s -X POST -d {"at_home":1} http://localhost:8080/api/v1/key/telemetry --header "Content-Type:application/json"')
        at_home = False
        print "pretentious: out"
        os.system('curl -s -X POST -d {"at_home":0} http://localhost:8080/api/v1/key/telemetry --header "Content-Type:application/json"')
    if at_home:

is working for me. I'm a bit worried about the lookup function actually does because I don't want my phone constantly responding to bluetooth request messages or something, Hence the 10 minute delay when I expect a connection.

-- Tue Jul 04, 2017 1:05 pm --

So I've been making some interesting progress with this. But my cassandra db kept falling over. Apparently it's a somewhat known issue that cassandra craps it's pants when it's provided limited ram, or the kernel kills it. Thingsboards answer to this issue is top provide postgres support in the next version. I've got the branch checked out and I'm taking the progress, which is pretty fun. I was considering clustering my db with my kodi media center which I also use as a backup host, but that kinda defeats the whole purpose. I might as well host it all in the cloud then. I'm willing to wait on thingsboard because I'm not a fan of reinventing the wheel and this seems like the most mature general use and hackable solution that I've found

-- Wed Aug 16, 2017 8:40 pm --

We have lift off!!
I got impatient for the new release of thingsboard and cloned their pre release candidate from the master branch and got it working with postgres.

I've got a DHT22 sensor relaying info back to the server and the raspberry pi is handling like a charm. Some networking issues with the esp8266 but that's what I get for using code I don't really understand. I'll upload screenshots when I have some sexy data trends to show off ;)

Re: thinger IOT project

PostPosted: Wed Apr 18, 2018 12:11 pm
by CoraDias
Hi...i am a new user here. In my case I have started to make a LCARS gui in QT, on my main linux box, and the idea is that it will interface with the raspberry pi and get the sensor data from there and also it can send commands to the rpi, which lights it should turn on / off etc.

Re: thinger IOT project

PostPosted: Wed Jul 18, 2018 3:39 pm
by JohnyWalter
I would have been so disappointed if there wasn’t a JL PI-card Gif at the end of that. I’m sure Rob Z will understand, though he’ll make you pay ;o)

Gonna have to take this great project for a spin.