[HELP] Real Time IoT Dashboards with CMStick and Thinger.io

I’ve been browsing thinger.io YT channel and I stumble upon this video https://www.youtube.com/watch?v=r7RANgwbsfY, where he can change the sampling rate to less than 1 second. Do you have a tutorial or sample code for this?

He is using the streaming resources.

You can find more docummentation here:

http://docs.thinger.io/arduino/#coding-streaming-resources

Thank you for your reply! I was able to make it work on NodeMCU by editing the sample code but I’m having trouble on making it work on Raspberry Pi. Is it possible to make it work on Pi?

Hi @Tim_McKie, what are you doing that requires a sub-second update? just curious :slight_smile:

For make it work on the RPI, you need to change part of the code where the device sleeps for new data. Currently it wais for a second… Lowering it, you will be able to improve the streaming frequency.

Bests.

Hello @alvarolb, I’m trying to create an accelerometer to monitor the motion of Pi. I was able to stream websockets on my nodemcu but I cannot make it work on my Pi. BTW this is my code

#include "thinger/thinger.h"
#include <wiringPiI2C.h>
#include <stdio.h>
#include <math.h>

#define USER_ID             "---"
#define DEVICE_ID           "---"
#define DEVICE_CREDENTIAL   "---"

int fd;
int acclX, acclY, acclZ, temp; //raw data
double acclX_scaled, acclY_scaled, acclZ_scaled, temp_scaled;

int read_word_2c(int addr)
{
	int val;
	val = wiringPiI2CReadReg8(fd, addr);
	val = val << 8;
	val += wiringPiI2CReadReg8(fd, addr+1);
	if (val >= 0x8000)
	val = -(65536 - val);
	return val;
}

int main(int argc, char *argv[])
{
    thinger_device thing(USER_ID, DEVICE_ID, DEVICE_CREDENTIAL);
    
	fd = wiringPiI2CSetup (0x68);
	wiringPiI2CWriteReg8 (fd,0x6B,0x00);//disable sleep mode 
	printf("set 0x6B=%X\n",wiringPiI2CReadReg8 (fd,0x6B));
	
    // define thing resources here. i.e, this is a sum example
    thing["MPU6050"] >> [](pson& out){
		acclX = read_word_2c(0x3B);
		acclY = read_word_2c(0x3D);
		acclZ = read_word_2c(0x3F);
		temp = read_word_2c(0x41);
		acclX_scaled = acclX / 16384.0;
		acclY_scaled = acclY / 16384.0;
		acclZ_scaled = acclZ / 16384.0;
		temp_scaled = temp / 340 + 36.53;
		//printf("X: %f\t", acclX_scaled);
		//printf("Y: %f\t", acclY_scaled);
		//printf("Z: %f\t", acclZ_scaled);
		//printf("Temp: %f\n", temp_scaled);
		out["Ax"] = acclX_scaled;
		out["Ay"] = acclY_scaled;
		out["Az"] = acclZ_scaled;
		out["Temperature"] = temp_scaled;
    };

    thing.start();
    return 0;
}

I tried to put thing.stream(thing["MPU6050"]); but it still doesnt work.

Are there any recommended methods or steps to seamlessly connect my spacebar counter data to Thinger.io for real-time monitoring or analysis?"