user1793315Johi
Published © GPL3+

Record Arduino Variables Into a PC File

8 lines of code to setup and 1 line of code per variable for the Arduino, no programming on the PC side. USB-WiFi-Ethernet-Serial.

IntermediateFull instructions provided5,866
Record Arduino Variables Into a PC File

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
Any board will do, Uno, Mega, MKR, Due, ESP8266
×1
DS18B20 Programmable Resolution 1-Wire Digital Thermometer
Maxim Integrated DS18B20 Programmable Resolution 1-Wire Digital Thermometer
×1
Glass of water
×1
Tripod
This is a support to hold the DS18B20 in the glass of water
×1

Software apps and online services

WawiLib

Story

Read more

Code

Read DS18B20 temperature and expose variable temperature for reading by WawiLib

Arduino
// read temperature DS18B20
#include <OneWire.h> 
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

OneWire oneWire(8); 
DallasTemperature sensor(&oneWire);

// WawiLib library (lines 1&2):
#include <WawiSerialUsb.h> 
WawiSerialUsb WawiSrv;     

float temperature;

// make variable temperature visible to WawiLib (lines 3&4):
void wawiVarDef()          
{
  WawiSrv.wawiVar(temperature); 
}

void setup() 
{
    // Initialize serial object and WawiSerialUsb object (lines 5&6)
    // Init serial port (over USB):
    Serial.begin(115200);  
    // Init WawiSerialUsb object
    WawiSrv.begin(wawiVarDef,Serial,"Empty Demo Arduino"); 
}

void loop()
{
    // read DS18B20 values
    sensor.requestTemperatures(); 
    
    // wait a bit, but keep communicatoin allive (line 7)1
    WawiSrv.delay(100);
    
    // read actual temperature: 
    temperature=sensor.getTempCByIndex(0);
    
    // WawiLib housekeeping (line 8)
    WawiSrv.loop();
}

Credits

user1793315
2 projects • 1 follower
Contact
Johi
2 projects • 0 followers
Contact

Comments

Please log in or sign up to comment.