This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <ArduinoModbus.h> | |
// How often (in milliseconds) the sensors will be read. | |
const unsigned long REPORT_INTERVAL = 1000; | |
void setup() { | |
Serial.begin(9600); | |
while(!Serial); | |
if (!ModbusRTUClient.begin(9600)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const iconWindowHTML = (data, iconsData) => { | |
const iconWindowElement = document.createElement('div'); | |
iconWindowElement.classList.add('card', 'marker-window'); | |
const iconsHTML = Object.values(iconsData).map(iconData => { | |
if(!iconData?.icon){ | |
return ''; | |
} | |
return ` | |
<div class="d-flex flex-column align-items-center mr-1"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// html for the marker | |
const iconHTML = (attr,percent,value,colors,unit) => { | |
if(attr === "battery"){ | |
return ` | |
<div title="${value}${unit}" class="marker"> | |
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="30" viewBox="0 0 55 120"> | |
<rect x="10" y="7" width="45" height="102" stroke="black" fill="white" stroke-width="5"/> | |
<rect x="12" y="${107-percent}" width="40" height="${percent + 1}" stroke="black" fill="${colors.background}" stroke-width="0"/> | |
<rect x="12" y="30" width="20" height="4" fill="black" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const buildIcon = (data,attr) => { | |
const value = data.attributeValues?.[attr]; | |
const meta = data.attributes?.find(a => a.name === attr); | |
if(!value || !meta){ | |
throw new TypeError('Missing values'); // value at this point is string, so "0" won't fail | |
} | |
const min = meta.attributeTags?.min ? Number(meta.attributeTags.min) : 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// set up individual marker | |
const setUpMarker = (id, data) => { | |
if(!data.attributeValues?.location){ | |
return false; | |
} | |
// Pull marker from dictionary, or create new | |
let marker = markers[id]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Excerpt from https://github.com/Losant/google-map-advanced-markers/blob/main/custom-head-content.html | |
// Initialize globals | |
const markers = {}; | |
let devices = []; | |
let map; | |
let numSelected = 0; | |
let AdvancedMarkerElement; | |
let bounds; | |
let selectedAttribute = $('#attribute-selector').val() || 'battery'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example for reading temperature and humidity | |
* using the DHT22 and ESP8266 | |
* | |
* Copyright (c) 2016 Losant IoT. All rights reserved. | |
* https://www.losant.com | |
*/ | |
#include "DHT.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example for sending temperature and humidity | |
* to the cloud using the DHT22 and ESP8266 | |
* | |
* Copyright (c) 2016 Losant IoT. All rights reserved. | |
* https://www.losant.com | |
*/ | |
#include "DHT.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <LiquidCrystal_I2C.h> | |
// Construct an LCD object and pass it the | |
// I2C address, width (in characters) and | |
// height (in characters). Depending on the | |
// Actual device, the IC2 address may change. | |
LiquidCrystal_I2C lcd(0x3F, 16, 2); | |
void setup() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
BATTERY_DATA_FILE = "battery-state-reports-last-30-days.csv" | |
df = pd.read_csv(os.path.join(os.getcwd(), BATTERY_DATA_FILE)) | |
df.dtypes |
NewerOlder