Main Content

Results for

I'm trying to simulate EV drive system using FEM PMSM and IGBT block of simscape electrical.
The simulation results (magnitude of the current in time domain) is quite similar with the experimental results.
But in frequency domain analysis using FFT (fast fourier transform), amplitude of current harmonics(specially 5, 7 th of fundamental frequency) are way to different.
Is there any way that I could increase my simulation accuracy?
Hi, I'm trying to plot some real-time data recieved from an Arduino Uno R3 in matlab R2020b but I'm not sure what baudrate should I set for data transfer. In my case the higher the baudrate is better but if I cant graph it properly it would be of no value. I want to know if I set the baudrate to max (which is 2000000) and since every sample I recieve from arduino would be 10 bits long (it's a number between 0 to 1.1) will I be able to plot them in real time efficiently? is Matlab able to do that?
CPU: intel core i3 1005G1
I work with an Arduino device. I have subscribed separately two thingspeak devices that works properly. Every device has a channel and I would like to publish on both channel using an only device.
I have added the second channel to the first device(see image).
Althougt this device can publish on both channel separately, I can't publish at the same time (after a few seconds, obviously). When I try to publish both of then, no one works.
I am trying to simulate a single phase H-bridge inverter connected to a load in Simulink using Simscape Electrical (blue wire). The simulation does not work. I tested the same circuit (with black wire). And everything works fine. I looked hard, I can't see any reason. Does anyone know why or have any examples?
You can find the simulation files in the attachment.
My goal with this is to start with a basic inverter scheme before testing multilevel converters. I had started with that but I had problems from the beginning...
Thanks in advance
I'm trying to access the ThingSpeak channel from Unity using MQTTnet.
I tried the following, but the access failed.
options = new MqttClientOptionsBuilder()
.WithClientId(clientId)
.WithTcpServer("mqtt3.thingspeak.com", 1833)
.WithCredentials(username, password)
.WithTls()
.Build();
try
{
await mqttClient.ConnectAsync(options);
}
How do I access the channel to send and receive values?
Die
Die
Last activity on 27 Jun 2022

Hi there,
i prefere to develop my stuff in my windows-enviromet with VS-code. bur how to import the thingspeak-lib or module into vs-code so thate the code is running?
Hi everyone,
is it possible to see when a channel has been switched from a private to public view, a sort of timeline of activities?

The code is based on recording and sending data of heartbeat and temperature to the thingspeak channels but nothing displays

hello can some body help me regarding designing a project in simulink to estimate the state of health of a battery ?... including kalman filter .... at least i need the battery cell equivalent circuit in simulink and the idea of the estimation method

many thanks

Hey, so I have a simple air quality measurement IoT system but the values are not arriving in my ThingSpeak channel. I use basic tutorials for it and tried some kind of variation but the code is so simple, I don't see any problem code-wise. Maybe someone here can help me?
I am working with a Raspberry Pi 3 and the following code for a SDS011 sensor:
import time
from datetime import datetime
import paho.mqtt.publish as publish
import paho.mqtt.client as mqtt
import psutil
from sds011 import *
import aqi
sensor = SDS011("/dev/ttyUSB0", use_query_mode=True)
def get_data(n=3):
sensor.sleep(sleep=False)
pmt_2_5 = 0
pmt_10 = 0
time.sleep(10)
for i in range (n):
x = sensor.query()
pmt_2_5 = pmt_2_5 + x[0]
pmt_10 = pmt_10 + x[1]
time.sleep(2)
pmt_2_5 = round(pmt_2_5/n, 1)
pmt_10 = round(pmt_10/n, 1)
sensor.sleep(sleep=True)
time.sleep(2)
return pmt_2_5, pmt_10
def conv_aqi(pmt_2_5, pmt_10):
aqi_2_5 = aqi.to_iaqi(aqi.POLLUTANT_PM25, str(pmt_2_5))
aqi_10 = aqi.to_iaqi(aqi.POLLUTANT_PM10, str(pmt_10))
return aqi_2_5, aqi_10
def save_log():
with open("/YOUR PATH/air_quality.csv", "a") as log:
dt = datetime.now()
log.write("{},{},{},{},{}\n".format(dt, pmt_2_5, aqi_2_5, pmt_10, aqi_10))
log.close()
channelID = "YOUR CHANNEL ID"
apiKey = "YOUR WRITE KEY"
clientID = "YOUR CLIENT ID"
tUsername = "YOUR USERNAME"
tPassword = "YOUR PASSWORD"
topic = "channels/" + channelID + "/publish/" + apiKey
mqttHost = "mqtt3.thingspeak.com"
tTransport = "tcp"
tPort = 1883
tTLS = None
tProtocol = mqtt.MQTTv311
while True:
pmt_2_5, pmt_10 = get_data()
aqi_2_5, aqi_10 = conv_aqi(pmt_2_5, pmt_10)
print ("AQI2.5 =", aqi_2_5," AQI10 =", aqi_10)
tPayload = "field1=" + str(pmt_2_5)+ "&field2=" + str(aqi_2_5)+ "&field3=" + str(pmt_10)+ "&field4=" + str(aqi_10)
try:
publish.single(topic, payload=tPayload, hostname=mqttHost, port=tPort, client_id=clientID, auth={'username':tUsername, 'password':tPassword}, tls=tTLS, transport=tTransport, protocol=tProtocol)
print ("[INFO] Published data")
save_log()
time.sleep(60)
except Exception as e:
print ("[INFO] Failure in sending data")
print (e)
time.sleep(60)
We operate roughly 600 data loggers on Think Speak where there are roughly 150 gateways and each gateway communicates with a node. Our channels are labeled node# - gateway number and each number is 16 diigits. We have not found a wildcard search function so must have each number exactly right or we cannot find our channel. In some cases we wish to query a gateway and see which nodes are successfully communicating with it.
Hello All,
Ive started dabbling with thinkspeak and Matlab which allows me to put a few pens on th esame graph. I would love to be able to choose how far back from now to show on the graph via a date picker or something similar. I now I can code that in to matlab but then its fixed in code.
Thanks in advance
Hi, there ! Need some serious help.... I have trouble trying to upload my data to my Channel. Any ideas to fix it?
Below you can see my code:
#include <ThingSpeak.h>// Η βιβλιοθήκη του ThingSpeak.
#include <SPI.h>
#include <Ethernet.h>
#include <SoftwareSerial.h>
#include <Servo.h> // Η βιβλιοθήκη του σερβοκινητήρα.
#include "DHT.h"
#include "MQ7.h"
//Για τον αισθητήρα DHT11.
#define DHTPIN 7
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
//Για τον φωτισμό.
#define DELAY 5000 // Καθυστέρηση μεταξύ μετρήσεων σε ms για τον φωτισμό.
#define VIN 5 // Τάση 5V.
#define R 10000 //Αντίσταση 10.000 Ω.
//Για τον αισθητήρα MQ7.
int MQ7pin = A0;
int MQ7Reading;
int MQ7led = 3;
//Για τον αισθητήρα Soil.
int val;
int soil_dig= 8;
int soil_analog = A1;
//Μεταβλητές για τον φωτισμό και για τον υπολογισμό lux.
const int sensorPin = A3; // Το pin στο οποίο συνδέεται ο αισθητήρας.
const int led = 12;
const int greenled = 10;
const int redled = 4;
const long onduration = 10000;
const long offduration = 30000;
int ledstate = HIGH;
long remembertime = 0;
int sensorVal; // Αναλογική τιμή από τον αισθητήρα.
int lux; //Τιμές για τα lux
int valvePin = 13; // Το pin στο οποίο συνδέεται το ρελέ, ώστε να ενεργοποιεί την ηλεκτροβάνα.
//Για τον αισθητήρα Ultrasonic.
#define echoPin 5 // Το echoPin.
#define trigPin 6 // To trigPin.
long duration; // Η διάρκεια που κάνει το ηχητικό κύμα να ταξιδέψει.
int distance; // Ο υπολογισμός της ταχύτητας του ηχητικού κύματος.
//Για τον αισθητήρα Rain.
const int rain_D = 2;//Ψηφιακή τιμή αισθητήρα βροχής.
const int rain_A = A2;//Αναλογική τιμή αισθητήρα βροχής.
int rain_val;// Μεταβλητή για την αποθήκευση της τιμής του αισθητήρα βροχής.
int r;// Μεταβλητή για την αποθήκευση της τιμής του αισθητήρα βροχής.
Servo servo; // Το όνομα του σερβοκινητήρα.
int servoPin = 11; // Το pin στο οποίο συνδέεται ο σερβοκινητήρας.
#define pwm 9 // Το pin στο οποίο συνδέεται ο ανεμιστήρας.
//Σύνδεση
String readString;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //H mac address.
byte ip[] = {192,168,2,123};
EthernetClient client;
unsigned long myChannelNumber = 1*******; //Ο αριθμός του καναλιού.
const char * myWriteAPIKey = "****************"; //Το ΑΡΙ Κey του καναλιού.
const int updateInterval = 10000;
void setup() {
Serial.begin(9600);
ThingSpeak.begin(client);// Σύνδεση στο cloud του ThingSpeak.
dht.begin();
pinMode(MQ7led, OUTPUT);// Θέτει το led του MQ7 ως OUTPUT.
pinMode(trigPin, OUTPUT); // Θέτει το trigPin ως OUTPUT.
pinMode(echoPin, INPUT); // Θέτει το echoPin ως INPUT.
pinMode(rain_D, INPUT); // Θέτει το rain_D ως INPUT.
pinMode(rain_A, INPUT); // Θέτει το rain_A ως INPUT.
pinMode(servoPin, OUTPUT);// Θέτει το servoPin ως OUTPUT.
servo.attach(servoPin);// Σύνδεση σε pin της μεταβλητής του σερβοκινητήρα.
analogWrite(pwm, 255);// Γράφει μία αναλογική τιμή (PWM pin) σε ένα pin.
pinMode(soil_analog, INPUT); // Θέτει το soil_analog ως INPUT.
pinMode(soil_dig, INPUT);// Θέτει το soil_dig ως INPUT.
pinMode(valvePin, OUTPUT); //Θέτει το 13 ως OUTPUT pin, ώστε να στέλνει σήμα στο relay.
pinMode(led, OUTPUT); // Θέτει το ledPin ως output.
digitalWrite(led,ledstate);
pinMode(sensorPin, INPUT);// Θέτει το sensorPin ως INPUT.
pinMode(greenled, OUTPUT);// Θέτει το greenled ως OUTPUT.
pinMode(redled, OUTPUT);// Θέτει το redled ως OUTPUT.
}
void loop() {
Serial.println(F("======================================"));
Serial.println(F("Συνθήκες στο Θερμοκήπιο :"));
//DHT11
float t = dht.readTemperature();// Η θερμοκρασία σε °C.
float h = dht.readHumidity(); // Η υγρασία του χώρου.
float f = dht.readTemperature(true); //Η θερμοκρασία σε °F.
// Υπολογισμός του heat index, ο οποίος πρέπει να μετατραπεί σε Fahrenheit.
float hi = dht.computeHeatIndex(f, h);
Serial.print(F("Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(F(" and "));
Serial.print(f);
Serial.print(F("°F\t"));
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F(" %\t"));
Serial.print(F("Heat index: "));
Serial.print(hi);
Serial.println(F(" °F"));
// Έλεγχος της θερμοκρασίας , ώστε να ενεργοποιείται ο ανεμιστήρας όποτε χρειάζεται.
if (t == 26)
{
analogWrite(pwm, 51);
Serial.print(F("Ταχύτητα ανεμιστήρα: 20% "));
delay(1000);
}
else if (t == 30)
{
analogWrite(pwm, 204);
Serial.print(F("Ταχύτητα ανεμιστήρα: 80% "));
delay(1000);
}
else if (t > 40 )
{
analogWrite(pwm, 255);
Serial.print(F("Ταχύτητα ανεμιστήρα: 100% "));
delay(1000);
Serial.print(F("\t"));
}
//MQ7
float g = analogRead(MQ7pin);
Serial.print(F("MQ7: "));
Serial.println(g);
// Έλεγχος της τιμής του MQ7, ώστε να ανάβει το led που αναπαριστά ανεμιστήρα.
if ( g < 200)
{
Serial.println(F("O ανεμιστήρας κλειστός - Φυσιολογική ποσότητα CO στον χώρο εργασίας."));
digitalWrite(MQ7led, LOW);
}
else if (201 < g && g < 220)
{
Serial.println(F("Η μέγιστη φυσιολογική ποσότητα CO για χώρους εργασίας ξεπεράστηκε!!!- Λειτουργία εξαερισμού στο 50%."));
digitalWrite(MQ7led,HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(MQ7led, LOW); // turn the LED off by making the voltage LOW
delay(1000);
}
if (g > 220)
{
Serial.println(F("Eπικίνδυνα αέρια CO !!!- Λειτουργία εξαερισμού στο 100%."));
digitalWrite(MQ7led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(5000);
}
//Soil Humidity
int soil_analog_value = analogRead(soil_analog);
soil_analog_value = map(soil_analog_value, 0, 1023, 230, 0);//Συνάρτηση map για μετρατροπή τιμής σε %.
val = digitalRead(soil_dig);
Serial.print(F("Soil moisture (Αναλογική τιμή) : "));
Serial.print(soil_analog_value);
Serial.print(F("\t"));
//Έλεγχος υγρασίας εδάφους για αυτόματο πότισμα.
if (soil_analog_value < 50)
{
digitalWrite(valvePin, LOW); //Όταν η τιμή γίνει LOW,τότε και το relay πρέπει να λάβει τιμή LOW.
Serial.println(F("relay on"));
}
else
{
digitalWrite(valvePin, HIGH); //Όταν η τιμή γίνει HIGH, τότε και το relay πρέπει να λάβει τιμή HIGH.
Serial.println(F("relay off"));
}
//Ultrasonic Sensor
// Αρχικοποίηση του trigPin.
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Το trigPin σε HIGH (ACTIVE) για 10 μs.
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
//Διαβάζει το echoPin, επιστρέφει το χρόνο του ηχητικού κύματος σε μs.
duration = pulseIn(echoPin, HIGH);
// Υπολογισμός απόστασης.
distance = (duration - 10) * 0.034 / 2;
Serial.println("");
Serial.print(F("Distance: "));
Serial.print(distance);
Serial.print(F(" cm"));
//Rain Sensor
rain_val = digitalRead(rain_D);
r = analogRead (rain_A);
r = abs ((100*r-40000)/623);
Serial.println(F(""));
Serial.print(F("Rain (Αναλογική τιμή) :"));
Serial.print(r);
Serial.print(F("\t"));
Serial.print(F("Rain (Ψηφιακή τιμή) :"));
Serial.print(rain_val);
//Έλεγχος για λειτουργία του σερβοκινητήρα.
if ((rain_val != HIGH) && (distance < 9)) {
servo.write(0);
}
if ((rain_val != HIGH) && (distance > 9)) {
servo.write(90);
}
else {
servo.write(0);
}
//Μέτρηση τιμής της φωτοαντίστασης και μετατροπή σε lux.
sensorVal = analogRead(sensorPin);
lux=sensorRawToPhys(sensorVal);
Serial.print("Raw value from sensor= ");
Serial.println(sensorVal); //Τύπωση αναλογικής τιμής.
Serial.print("Physical value from sensor = ");
Serial.print(lux); //Τύπωση αναλογικής τιμής.
Serial.println(" lumen");
//Συνθήκες για το άνοιγμα των led και των κουρτινών σκίασης σε διάφορες γωνίες.
if (ledstate == HIGH){
if((millis() - remembertime) >= onduration){
ledstate = LOW;
remembertime = millis();
}
}
if (ledstate == LOW){
if((millis() - remembertime) >= offduration){
ledstate = HIGH;
remembertime = millis();
}
}
//Lux.
if (lux < 100){
digitalWrite(led, HIGH);
if (lux < 200){
digitalWrite(greenled, ledstate);
if (lux < 300){
digitalWrite(redled, ledstate);
}}}
if(lux > 350){
digitalWrite(redled, LOW);
if(lux > 450){
digitalWrite(greenled, LOW);
if (lux>600){
digitalWrite(led, LOW);
}}}
else
digitalWrite(led,ledstate);
//Τα δεδομένα για το ThingSpeak, τα οποία στέλνονται στα αριθμημένα fields.
ThingSpeak.writeField(myChannelNumber,1,t, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber,2,h ,myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber,3,g ,myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber,4,soil_analog_value, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber,5,distance, myWriteAPIKey);
ThingSpeak.writeField(myChannelNumber,6,r, myWriteAPIKey);
delay(15000);
}
int sensorRawToPhys(int raw){
// Conversion rule
float Vout = float(raw) * (VIN / float(1023));// Conversion analog to voltage
float RLDR = (R * (VIN - Vout))/Vout; // Conversion voltage to resistance
int phys=500/(RLDR/1000); // Conversion resitance to lumen
return phys;
}
Hi all,
I am trying to create a complete learning unit online using laravel. The unit of work is in Internet of Things. Hardware will be provided to students - Its a microbit plus the DFRobot Environment science expansion kit (https://www.dfrobot.com/product-2194.html) . All the video tutorials and project work is assigned via the laravel lms.They will log into the lms via their microsoft logins.
My next step is to simplify the process of users accessing the mathworks account. I would like to pre assign channels for students with API keys to write sensor values from each of their microbit shields to the cloud.
Has anyone tried to do this or has any suggestions how to?
The advantages of students having their own channels on my account is for me to monitor how they are progressing. These are year 9 students at high school who have never done any IoT or mathworks/thingspeak related content before.
J Slade
J Slade
Last activity on 31 May 2022

After leaving a Thingspeak trend tab dormant for a period of time, when I reopen it, numerous data points are missing:
After I refresh the tab, all the data points fill back in:
Any ideas what causes this and how to prevent it?
Thanks
I found I have to use VPN to access my thingspeak data channels from China. Is this a known problem? if yes, anything I can do to solve the problem?
I am trying to write a table to a TS channel using thingSpeakWrite. The code below results in error but the help documentation indicates that it can be done. Any suggestion on how to fix this?
Function to call:
thingSpeakWrite(channelID,ship1(1,:),'WriteKey',writeAPIKey);
The complete code:
%Initialize table to be written to ThingSpeak
varNames = ["MMSI", "LAT", "LONG", "SOG", "VesselName", "VesselType", "Length", "Width"];
varTypes = ["double", "double", "double", "double", "categorical", "double", "double", "double"];
ship1 = table('Size',[20 8],'VariableTypes',varTypes,'VariableNames',varNames);
ship1.MMSI(:) = 121212;
ship1.SOG(:) = 10;
ship1(:,5) = {'PRIMODY'};
ship1(:,6) = {37};
ship1.Length(:) = 20;
ship1.Width(:) = 12;
thingSpeakWrite(channelID,ship1(1,:),'WriteKey',writeAPIKey);
Hello everyone, I need some help, I am developing a POC for a TCC using the DEMO itself "Example of HTTPS GET with SoftwareSerial and Arduino-SIM800L-driver" and when sending the data I am receiving a 606 error, does anyone have any idea of what it might be and how to solve it, I've validated the string sends through POSTMAN and it's ok.
SIM800L : Receive "AT+HTTPPARA="URL","https://api.thingspeak.com/update?api_key=XXXXXXXXXXXXXXX&field1=-23.5204435&field2=-46.5078319&field3=10&field4=600"
OK
"
SIM800L : Send "AT+HTTPPARA="REDIR",1"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPPARA="REDIR",1
OK
"
SIM800L : Send "ATI"
SIM800L : End of transmission
SIM800L : Receive "ATI
SIM800 R14.18
"
SIM800L : initiateHTTP() - Support of SSL enabled
SIM800L : Send "AT+HTTPSSL=1"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPSSL=1
OK
"
SIM800L : Send "AT+HTTPACTION=0"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPACTION=0
OK
"
SIM800L : End of transmission
SIM800L : Receive "
+HTTPACTION: 0,606,0
"
SIM800L : readHTTP() - HTTP status 606
SIM800L : Send "AT+HTTPTERM"
SIM800L : End of transmission
SIM800L : Receive "AT+HTTPTERM
OK