Logo
  • start
LinkedIn
🌐

Connected Devices

Connected Devices

  • Connected Devices
  • Home networking
  • SSH, Networking - April 15
  • What else should I check?
  • Sources
  • Node.js
  • What are these lines of code doing
  • Most basic way of creating a server in terminal
  • Create project with npm init
  • Nginx / VPS (Node with Nginx - see script under examples)
  • To make a Post request
  • API
  • Success with the assignment
  • Final semester project: interfacing with an API + create physical interface
  • Physicality
  • Internet Archive API
  • APIs +
  • Hue Controller
  • Issues / Future additions
  • Project Requirements
  • Component list
  • Libraries
  • References / Code Samples
  • NeoPixel References
  • First step: using ArduinoHTTP Client HueBlink example
  • Using browser dashboard to query the state of all lights
  • Connection to Rotary encoder
  • Planning out my circuit
  • Ceiling Fan Switch
  • NeoPixel Visualization
  • Errors
  • C++ is case sensitive
  • Improving response time
  • Nothing is changing yet, I’m making a put request to the server
  • Class Notes
  • Project
  • Final project
  • Bluetooth
  • Visualizing
  • Final Midterm Project Documentation
  • Aspirational project description
  • Reality-based project description
  • Angles of this project (written on Week 6)
  • Dashboard
  • Data Conclusions / Updates since last session
  • Rough state buckets for House Energy: Connected; Isolated and Empty
  • Data Processing Pipeline (Chart)
  • Next steps
  • System Diagram
  • Wiring Diagram
  • Enclosure Experiments
  • Current enclosure
  • Credits and development notes
  • art via emotion through data
  • Week 7: Data Analysis
  • Data Unknowns
  • Done
  • Important to do
  • Next steps depending on how much energy I can budget for this
  • Adding active device count to dataset
  • Scanning devices within Networks
  • Questions
  • Added ESPing library
  • Project Documentation should include,
  • Data Visualization
  • Week 6: March/04 → Post Office Hours Conclusions // Defining architecture and society within it
  • Human-AI Interaction ⭐️ 😮 Human-Computer Interaction ❌
  • To discuss with Tom
  • Full Stack Builder
  • I see the (architectural) light 🕯️
  • Week 6: Questions for Tom’s office hours
  • Office Hours with Fabri - Week 6 - March 4th, 2026
  • Wires
  • Soldering
  • Week 6 - Device 1 - Environmental Data with MQTT
  • MQTT
  • Running on VPS
  • Wifi/DensePose experiment
  • Next steps and existential programmatic questions and interesting finds and thought ships (trains are too slow for this analogy ha)
  • Solid enclosures and circuits; next steps
  • Interface
  • Data / sensor selection next steps
  • In Class Notes
  • Week 4 and 5 - Device 1
  • V1
  • Eletronics in my project
  • Next steps
  • Week 3
  • Tech vs Regulation
  • Virtual Private Server
  • Rabbit hole of questions semi solved through writing
  • For an upcoming rabbit hole,
  • Week 2
  • Final Dashboard
  • Scan Networks Sketch Serial Monitor:
  • Running WiFiTCPClient Logger
  • Q: is there a reason to be replacing instead of using the value directly?
  • Q ✅
  • Answer:
  • Useful Commands
  • Making the dashboard interesting
  • Week 1
  • Electronic devices in my routines
  • Network Topologies
  • Network Infrastructure
  • Command Line Tools
  • Command Line Tools
  • HTTP Protocol

Home networking

someone gave me a really good explanation of what ssh public vs private keys are, involving japanese stamps. each device has 2 only. The stamp is the same but the inprint left by it is different - because it’s hashed. Public keys are available even online through github for anyone to see. they’re what i’d give someone that wants to give me access to their service.

Next steps are tailscale which routes traffic; and syncthing.

Lawrence Systems Syncthing Tutorial: Open Source & Private File Sync Made SimpleLawrence Systems Syncthing Tutorial: Open Source & Private File Sync Made Simple

disabling no/other usernames on my vps.

SSH, Networking - April 15

Recently I’ve learned a lot about LoRa, Reticulum, Meshtastic, MeshNodes + Networking, jailbreaking, remote access to a server, how SSH keys are per device and some senses of criptography.

The most key discovery is that for my Digital Ocean Droplet SSH, there’s an extra setting needed to prevent password access and hacks. “On Ubuntu 22.04+ and Debian 12+, you must also set the PasswordAuthentication setting to yes in both /etc/ssh/sshd_config.d/50-cloud-init.conf and /etc/ssh/sshd_config.”

DigitalOcean I lost the SSH key for my Droplet | DigitalOcean DocumentationDigitalOcean I lost the SSH key for my Droplet | DigitalOcean Documentation

image

PasswordAuthentication no PubkeyAuthentication yes ChallengeResponseAuthentication no

On /etc/ssh/sshd_config.

This is a reminder that when I change computers I need to remember to add another SSH key before resetting it fully. Or carry a flashdrive. I’ve met someone with one with a brand of “V”.

What else should I check?

  • If I SSH in without a hostname, it still however asks for password.
  • ➜  ~ ssh living.ines.systems
    ineslucas@living.ines.systems's password:
    
    // Strange since I've disabled anyways remote access.
    // Here ineslucas is my local machine's username, not an allowed host name. 
    
    // To check all users. Most will be system accounts.
    cat /etc/passwd
    
    // And even the right password seems to get denied.
  • Test if someone ssh’ing with the correct hostname but on another machine is still prompted for a password.
  • In addition to sshd_config, there’s also a ssh_config file outlining other types of auth.
  • Check usePam implications.
  • If you lose your SSH key, Digital Ocean’s solution currently is to use their web console and I wonder what kind of security vulnerability does that present.

Sources

Ask Ubuntu Why is "50-cloud-init.conf" created?Ask Ubuntu Why is "50-cloud-init.conf" created?

itp.nyu.edu
Networks Website

Node.js

NodeExamples by Tom (see datalogger, encryption, ExpressIntro(this example!), Conn Dev Client, proxyServer.js): Embed GitHubEmbed GitHub

/NodeExamplesTom/NodeWithNginx/proxy-server.js

Node.js is simply running JavaScript on the terminal as opposed to in the browser. Node.js is to JS what Arduino IDE is to C++.

Express → library used specifically to ???????????.

Makes a WebServer in 4 lines of code.

What are these lines of code doing

Requesting from the Operating system to a particular port

will listen to incoming requests on that port

will listen specifically to HTTP formatted requests.

server.js is the actual program

package.json describes the program’s dependencies. Some programs use manifest.js

public > index.html

node_modules

  • Folder should only be removed from GitHub, not to spam their servers.
  • But also these libraries are installed with npm install - list is read from package.json.

If we were using LiveServer, Express, npm ——— all these are programs that serve files.

Most basic way of creating a server in terminal

mkdir newProject
cd newProject
touch script.js
code script.js // Add console.log("Hi there!")
node script.js

Create project with npm init

Nginx / VPS (Node with Nginx - see script under examples)

Nginx is the gateway for all these microservices. Responds to static file requests.

By having a single gateway, Nginx within the port (and IP address && remote access

If Nginx dies, another port is supporting this.

Nginx and Node communicate

body-parser

Remote sessions between two hosts - what governs those? Typically we have our session open for discrete requests

node proxy

ps -a to see all processes we’re running.

man ps manual for ps command

If we kill the terminal, we kill the process that terminal was running.

pm2

PM2 list → program which runs various scripts as constant services.

There various process into a service.

What separates a process and a service?

syscontrols for more experienced programmers

Q: what is

To make a Post request

Option #1: curl -X POST “https://tigoe.net/garden/data?hello’

Option #2: make an input element, event listener,

I’m now realizing I get excited about different protoboards like i do about

TrafficCams host didn’t want to

Button triggers GET request.

Q: Tom was showing available routes and a process shutting down everythiung w no route.

Book time w Tom

ask kezia jpg decoding.

API

  • curl ‘XXXXX’ >> asteroid.json
  • Format JSON
  • VS Code: Command K + Command D
  • Curl + SDK +
  • openlibrary.org
  • MIKROE mikroSDK - Software Development Kit - MIKROEMIKROE mikroSDK - Software Development Kit - MIKROE

Success with the assignment

Comfortable with APIs and can describe why.

PUT requests.

API results very complex and very

2 part files that are linked: download metadata + file itself.

Where does API call from?

Time it takes for processor to send to card.

Middleman host that only takes from data what is needed.

Co-processor + Side-processor.

Anything with an operating

Co-processors: Local + server.

Tom’s lab

Tom called each program in his Mac a process. Refers back to the kill process / Application but also to the idea that each terminal session is an instance and therefore running a process. Any process can eventually be scaled up to an application.

To think about —- how many processes do I have running as a person?

Final semester project: interfacing with an API + create physical interface

Area of Interest: Single purpose devices, Interactive Furniture, Wearable Physical Archives.

I’m interested in checking provenance of media. I will be working with the Internet Archive API.

More research needs to be done, but each piece of media transferred in via WiFi (through thesis devices) will be subject to a reverse image search or Wayback Machine lookup. This is an unplanned extension of my thesis d2d (device2device?) sharing, hopefully for a show where folks can donate content to a common (physical) space, that so far has only existed in the other dimension (the internet).

If content can’t be found, it gets added. How are duplicates seen in this belief system?

The goal is to outline the life of an internet artifact → eg. first published in X; seen around the internet X times. Eventually, I’d love to create an endangerment score, mixing Google Trends data with Wayback Machine + reverse image search.

If i’m serious about this, the real findings come from analysing what do endangered internet artifacts have in common. Communities, distribution - what does each tree look like.

Connecting unknown, unlinked (edit for logic consistency) source material that arrives through the private network back to a common (family?) tree (OSS ref).

Links back to how we get news today - shaped by algorithms and social websites, that make it harder to back link anything for their own profit. The loss of the link means loss of provenance. This links back to the right to access information. Information, in order to be worthy of that name, needs to be informative - that includes checks, sources and access to the life of this media artifact.

This way, we’re making physical presence a requirement for sharing files, donating them to a common bank and contextualizing them right after to common ground.

>>>>>> Tree analogy

Until finding this API and reading docs, it had not occurred to me that there’s an obvious field of research here within internet media artifacts where so many fun links can be drawn to other social science findings and I don’t think I’ve seen other researchers define it in this way… hm!

Edit: I’m wrong:

The Bit List 2024: Global List of Endangered Digital Species - Interim Review | Policy CommonsThe Bit List 2024: Global List of Endangered Digital Species - Interim Review | Policy Commons

Physicality

There’s a home version and an archive station version of this. I’m inclined to do whatever Archive Station version of this is possible within the timeline.

  • Home: Media collected during the day gets offloaded at night to a sanctuary of sorts / evening routine-esque. With a little connector and magnets (tbd?). Each node or pod returns to a piece of furniture with a screen or light indicator. Data caretaker reunites data with provenance. Connects source material to source. Personal or family device.
  • Archive Station (Cyber Deck adjacent?)
    • Square Monitor + Pink Monochrome Display (which has a radio antenna → for future projects!)
    • Can jailbreak wireless Playstation controller to control this station.
      • #TODO follow threads further
        www.google.com 🔎 jailbreak wireless controllers ps as a web server - Google Searchwww.google.com 🔎 jailbreak wireless controllers ps as a web server - Google Search
      • #TODO Test power: I got 2 PS controllers for 4$ today, that I need to do a quick power test on.

Internet Archive API

Coincidentally, after choosing API and mapping out device flow, just saw this Wired article from 2 hours ago on many journalism entities blocking the wayback machine despite relying on it for research:

Kate Knibbs The Internet's Most Powerful Archiving Tool Is in PerilKate Knibbs The Internet's Most Powerful Archiving Tool Is in Peril

PDF analysis, generation and compression at the Internet Archive — Internet Archive Developer PortalPDF analysis, generation and compression at the Internet Archive — Internet Archive Developer Portal

Command-Line Interface — Internet Archive Developer PortalCommand-Line Interface — Internet Archive Developer Portal

Wayback Machine APIs | Internet ArchiveWayback Machine APIs | Internet Archive
⭐️

Wayback CDX Server API

APIs +

Wikipedia Wikipedia:RandomWikipedia Wikipedia:Random
+
MediaWiki API:Random - MediaWikiMediaWiki API:Random - MediaWiki

Are.na Developers | Are.naAre.na Developers | Are.na

Phillips Hue API (Change light based on state of archive + NeoPixel integration?)

Custom endpoint? (Open Source own project)

Hue Controller

This Hue controller for one of the lights on campus uses a ceiling fan switch to turn on and off, a force sensing resistor to turn down brightness, a rotary encoder to change the hue and a NeoPixel strip to visualize the current status of the light.

Source code available on GitHub, missing a push. Has production code but also credited examples for testing each component separately.

Issues / Future additions

  • Need to find a smoother way to diminish the light strip light.
  • Look into API transitions.
  • Re-map rotary encoder to move through hues quicker.
  • Review code especially with the intention of calling the API the minimum possible.

Project Requirements

Physical interface for turning lights on and off, dimming them, and changing color. Use the Hue system and lamps that are on the floor at ITP.

Component list

  • Arduino Nano 33 IoT
  • 8 Bits WS2812 RGB LED Stick
  • Rotary Encoder
  • Arduino Nano Screw Terminal Adapter
  • Ceiling Fan Switch
  • Protoboard, terminal blocks

Libraries

  • NeoPixel library → could also use FastLED Library (animations / efficiency?)
  • WiFiNINA
  • SPI
  • ArduinoHTTPClient
  • Encoder Step Counter

References / Code Samples

tigoe.net/hue-control

tigoe Real-Time Systems and Operating Systems
Rotary Encoders

ITP Physical Computing Lab: Using a Rotary EncoderITP Physical Computing Lab: Using a Rotary Encoder

Arduino Forum Using Push Buttons in Arduino Nano's Analog Input PinsArduino Forum Using Push Buttons in Arduino Nano's Analog Input Pins

Øyvind Nydal Dahl How Rotary Encoders WorkØyvind Nydal Dahl How Rotary Encoders Work

+ITP Phys Comp Controlling sensors for FSR

ITP Physical Computing Lab: Sensor Change DetectionITP Physical Computing Lab: Sensor Change Detection

itp.nyu.edu
Light and Interactivity, Philips Hue Control

hue-control Controlling the Philips Hue Bridge

hue-control Philips Hue Control from Arduino

Hue Info email from Tom

GitHub hue-control/client-example-js at main · tigoe/hue-controlGitHub hue-control/client-example-js at main · tigoe/hue-control

hue-control Controlling the Philips Hue Bridge

developers.meethue.com
Core Concepts

Tom Igoe Connected DevicesTom Igoe Connected Devices
Vimeo ArduinoHttpClient_hue_control

NeoPixel References

Adafruit NeoPixel Library: Adafruit_NeoPixel Class Reference

Sara Santos Guide for WS2812B Addressable RGB LED Strip with Arduino | Random Nerd TutorialsSara Santos Guide for WS2812B Addressable RGB LED Strip with Arduino | Random Nerd Tutorials

First step: using ArduinoHTTP Client HueBlink example

Code here

image

Using browser dashboard to query the state of all lights

Philips Hue debug dashboard (CLIP API Debugger)

http://172.22.151.226/debug/clip.html // IP Address for ITP_south_floor, accessible since through network

GET request to /api/$HUE_USER/lights or /api/QL6AHnxaf3-3YER9xoBCp8DRDsfweUcfuuAtmqP5/lights
image

Light 9 that was on at the time of testing did not respond to my PUT request to turn on, which is intriguing. I would have expected to see better error handling especially from being a Phillips API.

image

Only light 5 and 6 were responsive to my request.

image

Connection to Rotary encoder

Successfully controlling hue via Rotary Encoder but need to tweak the ranges. Updated base code in this commit.

[ add video ]

Planning out my circuit

I want to add a visualizer for color and dim level through the 8 Bits WS2812 RGB LED Stick.

image
image
image
image
image

It ended up being a circuit with more connections than required because I wanted to be able to use this protoboard in the future for other boards or because wire for ceiling fan switch wouldn’t fit in the Nano terminal adapters.

I realized I had the username on my GitHub commit history, so did git filter-branch --tree-filter to remove it from commit history.

git filter-branch --tree-filter ++++++ username content.

git for-each-ref refs/original

// Deleting the refs
git update-ref -d refs/original/refs/heads/main  
git reflog expire --expire=now --all
git gc --prune=now

// checking that it's all deleted
git log --all --oneline -S "(username)"
git for-each-ref refs/original

Ceiling Fan Switch

Using it to turn light on and off. We know when light is off through the API, not through switch state. In this case, LED strip should be off as well. I wonder if the API accounts for this because it didn’t seem to have good error handling for state at least?

NeoPixel Visualization

If there's 100% brightness, then all 8 NeoPixels should be lit up. If there's 0% brightness, no Neopixels should be lit up.

Could also use a circular NeoPixel around the rotary encoder to know which hue is currently selected.

Errors

C++ is case sensitive

Improving response time

Disabling other microcontroller functions to fire loop quicker?

transitionTime would smooth the bulb further, but bulb is already smoother than the strip.

I’ve reduced the amount of steps the rotary encoder needs to take to change hue, but perhaps would adding transition time be the answer?

time that it takes for message to get to network. Add fade.

Hallefect sensors. Read change in direction of magnetic field.

Read sensors all the time but only act when needed.

It would be so so fun to do a little wave between all the lights that includes moving the brightness through a sine wave.

Nothing is changing yet, I’m making a put request to the server

The reason to do this is preventing that someone else changes the light without my knowledge. But in this case I’m optimizing for visuals and responsiveness. Solution: writing to the API instead of letting the API write to the strip. Better yet, write to the bridge and the strip at the same time when changes happen to any of our sensors.

Alternatively, instead of making API calls / PUT requests from the controller into the bridge frequently, I can listen for rotary encoder events.

Pseudo Code

setup() {

  • make a put request for a specific light setting, including a transitionTime?

OR

  • get current light data and assign that starting point to light strip.

}

loop() {

  • listen for rotary encoder events,
  • if there’s change, make a put request for hue in the lights.

}

Arduino owns the state

Class Notes

ZigBee - no direct consumer pieces for it. Difficult documentation. There’s a push for Bluetooth now.

There’s some

The XPs could be programmed to be Hue Bulbs.

Everybody now makes things for Alexa and Google.

IFTT.

Hue allows for third parties.

Send transition time so that fade takes a second or two.

When system transitions a little slowly, we slow down in our expectations.

Soft buttons will change people’s expectations in responsiveness.

There’s potentiometers that go back to their original state.

How can we create feedback in our controls?

Tolerances;

What we’re seeing on networks doesn’t allow for real time.

Phillips HUE API has groups and scenes.

A phone can do everything. So how do you know what to do?

Project

Scanning for Radio signals. Wi-Fi is a form of radio technology. I keep forgetting. I’d like to understand why.

There’s an article around hacking into Lutron’s light switches from an ITP alum.

Document if I go down this path.

It would be so fun to create

>Functional Furniture?

Final project

About web based APIs. Explore an API and come up with a physical interface.

Pick one by next week, communicate that to Tom. Pick a partner.

Tide API from Noah - Tom’s fav API.

Bluetooth

Bluetooth LE became much more of a publish & subscribe model.

Bluetooth I

ToolBLEx  - Tom’s favorite.

LED.ino example.

Bluetooth also has RSSI.

Visualizing

There’s math on getting angle.

Gyrometer is measuring angle

Accelerometer is

See if up, down or sideways. You look for one of the axis to be reading maximum value.

Other option is that I can look at see X, Y, Z - which ever one is the highest I know that’s the side facing down. Where as, I can also look at minimums.

If axis is facing down AND X (???)

Design the thing so that people will do something predictable. If I’m doing an intangible controller, I’d need to add something gestural about it.

Gestural Sensor.

Final Midterm Project Documentation

Aspirational project description

Living Room Table center piece that has all the tools to spy on my roomates, yet it chooses not to. Instead of using the tools for survaillance, they’re choosing to preserve privacy, honesty and trust around home sharing and create vivid memory representations.

Reality-based project description

Center piece measuring a living room’s ecology. An exploration of what it means to obtain data through DIY means that large companies spend millions of dollars stockpiling. Combines number of devices connected to WiFi with magnetometer and presence sensor to define a loose picture of what technological and human forces surround the house at any given moment.

Angles of this project (written on Week 6)

  1. A possible pitch could be trying create FindMy for your roomates and communities but without big tech. Build / Breakup with FindMy or other tools meant to help document community.
  2. Having all the tools for surveillance at a hardware level but not using them at the software level. Whoever you live with can totally spy on you. And if families knew how to, they would.
  3. The idea that a space can call you towards it. If something is happening in the home, it’s drawing you towards the space. A beautiful wearable representation of this would be a Woven Light keychain?

Dashboard

Dashboard Link

image

Data Conclusions / Updates since last session

  • x, y, z axis of the magnetometer don’t hold much meaning. A square root of the 3 values combines it in an interesting way.
    • However, there’s still very much an issue. A microwave has registered at 180uT and 90uT.
  • PIR Digital Value - currently seen as Motion detected is very much useless.
  • With 1 PIR, it’s indistinguishable me walking around while my roomates sleep from all 3 of us at home.
  • WiFi Devices also seems to be spotty. Very little relationship to when flatmates get home, purely because we switch between devices regularly. TV is also included in this. 3D Printer as well. To have it be done accurately, I’d need to remove known devices. Maybe it is okay to check for a specific person’s devices presence but only to mantain a counter of who’s home.
    • To be clear, I do already have access to this information through Apple’s Find My. The question is, what is a way that creates lovely paintings and art visualization but doesn’t provide external actors with a way to map out household movements for nefarious reasons.
  • Graph on dashboard now allows me to overlay the data.

Rough state buckets for House Energy: Connected; Isolated and Empty

Each 1-hour time bucket is classified into one of three states using two signals from the sensor data: PIR Raw standard deviation (σ) measures activity in the sensor room, and WiFi device count average measures how many people are likely home.

Thresholds (could be tuned further!):

  • PIR_ACTIVE_THRESHOLD = 40 Above this means active presence in the room
  • PIR_QUIET_THRESHOLD = 15 Below this means nobody moving at all.
  • WIFI_HOME_THRESHOLD = 14 Above this means people are home. Didn’t manage to get a clear idea of how many.
State
Condition
Meaning
Connected
PIR Raw σ > 40
Active presence in the sensor room, regardless of WiFi count
Isolated
PIR Raw σ ≤ 40 AND (WiFi ≥ 14 devices OR no WiFi data)
People are home but not in this room
Empty
PIR Raw σ ≤ 40 AND WiFi < 14 devices
Quiet room, few devices on network
Empty (also)
PIR Raw σ ≤ 15 AND WiFi < 14 devices
No movement at all, few devices

Edge case: When PIR σ is between 15–40 and there's no WiFi data available (wifiAvg < 0), we’re defaulting to Isolated, assuming people might be home since it can't tell from WiFi alone. Our WiFi goes down constantly.

Note: The Z-axis magnetometer standard deviation is computed and displayed in the energy strip tooltip, but it does not drive the classification. It doesn't vary meaningfully with human activity based on 16 days of observed data.

Data Processing Pipeline (Chart)

The chart runs this pipeline on every 5-second fetch cycle:

  1. Ingest: parse line-delimited JSON from log.json, only processing new lines since the last fetch
  2. Filter: keep only points within the selected time window (1h / 6h / 24h / 7d / 30d)
  3. Downsample: min/max bucketing reduces up to 520,000 points → ~1,200 drawn points, preserving spikes and dips
  4. Draw: Each checked series is drawn independently on a shared canvas with dual Y-axes (left = µT, right = PIR/WiFi).

Next steps

I realized the only way this works really is through by using a microphone and doing FFT analysis only.

PIR’s optimization would be by having several. I got small ones with 3m range that I liked but never got around to redesigning the project. 3 in different directions would be ideal.

System Diagram

image

Wiring Diagram

image

Enclosure Experiments

image
image
image

I experimented with different designs. Ultimately, I want the final one to be similar to the above.

Before designing the final version, I need to protoboard the circuit so that I can be working with more flexible dimensions.

image

Current enclosure

Source Code: Embed GitHubEmbed GitHub

Inside the enclosure
Inside the enclosure
When covered
When covered
Pre-enclosure circuit
Pre-enclosure circuit

Credits and development notes

A number of early trials to check wiring and base function were done through library examples & Tom’s web page (TFT screen, Bosch’s and Waveshare’s documentation for the magnetometer, PIR too) and then combined at different points using Claude Code; created documentation for Readme file. Prototypes started with AI escalated into fuller features. There’s some regrettable choices, however… it works and it’s understandable to me, so it’s unclear how to feel about it.

Will compile a list of references ASAP.

This blog is, however, 100% handwritten.

Resource List

Code examples for initial build here on my GitHub:

GitHub common-room-pulse-esp32/code_examples at main · ineslucas/common-room-pulse-esp32GitHub common-room-pulse-esp32/code_examples at main · ineslucas/common-room-pulse-esp32

  • mqtt-examples MQTT Examples
Check Notion database of references

art via emotion through data

Inspiration

I aim to create visuals along these lines in a next phase of this project. My blocker right now is having arrived at the conclusion that my sensors aren’t massively reliable if I actually want any meaning to this, but also haven’t looked too much into what libraries I could use without getting too deep into shaders.

The end goal is to scroll through a timeline, and in a heatmap fashion, we see date/time and the energy of the home.

image
image
image
image
image

Follow this rabbithole

Week 7: Data Analysis

Room Magnetic Pulse

Data Unknowns

There’s several options….

  • Manual annotation - either via SSH scripts on my phone OR through web interface
  • Averaging, smoothing, or rolling windows
  • Rolling Windows
    Rolling Windows
  • Measuring anomalies or thresholds
  • Statistical aggregation (mean, median, standard deviation)
  • image
  • No cross-correlation between series

Done

✅ Fixed wiring issue from last week;

Now it’s standalone!

✅ Script to try connecting to Home and Sandbox WiFi Networks;

✅ ONLY if device is at home, check how many devices are active; starting logging which WiFi it’s connected to;

✅ Adding this to dashboard;

🤔 Did not implement, but researched/soldered mic; Thermal camera and different PIRs’ range

Important to do

Add firewall to my VPS
Move Web Server from Nginx to Vercel
Re-decide what to show in graph

Next steps depending on how much energy I can budget for this

  • Redesign enclosure to have different PIRs to be a center piece
  • Intersect data in a more interesting way
  • ✨ Artistic output ✨
    • Light center piece / wall mounted matrix;
image
image
image

little joys (SSH’ing into my server from my phone)

Adding active device count to dataset

Scanning devices within Networks

  • Nmap: the Network Mapper - Free Security ScannerNmap: the Network Mapper - Free Security Scanner
image

Questions

  • Excluding a scenario where someone is physically near my home network, what are the issues of sharing my WiFi Network name and password - to an LLM or online?
  • Or even the information of how many and which devices are connected to WiFi?
sysctl net.link.ether.inet.max_age
   // Check ARP cache entry lifetime in seconds. 
   // Mine is 1200 seconds or 20 minutes.
   // Since pinging every 20 minutes is perfect for the usecase, we don't need real time.

Added ESPing library

image

Project Documentation should include,

Systems Diagram
Short description of what we’ve made
Code Structure
Dashboard
  • uT MicroTesla;
  • re-do dashboard to be external facing;
  • do annotations;
  • commenting my code to learn it;
💡

Ask Yuliya for any data analysis;

Data Visualization

  • Canvas 2D API (ctx.beginPath(), ctx.lineTo(), ctx.stroke()) but could use Chart.js
  • d3.js
  • p5.js: x.y of the pixel, learning how to that;

Instagram Kai Lab on Instagram: "CMYK Searchspace 2.0 [ Aluminum Limited ] . First batch ready for delivery, second batch fast on its way to completion! Third batch available for pre order on the KAI shop! . CMYK Searchspace 2.0 is a fully analog colour synthesizer. No flicker, no PWM dimming a circuit from your old analog electronics text books.  . . Special thanks to @qiqi77art for all your help on assembling these! . #design #art #lightart"Instagram Kai Lab on Instagram: "CMYK Searchspace 2.0 [ Aluminum Limited ] . First batch ready for delivery, second batch fast on its way to completion! Third batch available for pre order on the KAI shop! . CMYK Searchspace 2.0 is a fully analog colour synthesizer. No flicker, no PWM dimming a circuit from your old analog electronics text books. . . Special thanks to @qiqi77art for all your help on assembling these! . #design #art #lightart"

Week 6: March/04 → Post Office Hours Conclusions // Defining architecture and society within it

💡

I’m trying update my map or logic system on meaningful work, personal data, artificial intelligence and economics considering what I’ve learnt in Connected Devices.

Thinking isn’t linear and neither is this succession of ideas. Might even be that the big conclusion is ommitted due to being to fundamental, visceral and obvious and triggering another idea. And another.

The future of computing is personal. What does that mean for hardware and custom controllers?

It’s me being able to centralize everything I’ve ever wanted at ines.systems and eventually ines.tools. Connect my home, my thoughts, give meaning to my data and proper use cases.

Different workspaces, different universes and interfaces for different projects and tasks on any given day. With different looks and tools. Similar ethos to the Nothing Phone.

Building this won’t get you any accolades because someone has already built open source dashboards for home IoT DIY, that even connects to your printer via WLAN.

BUT it does give your life excitement and privacy and control.

If someone has already open sourced it and in a world of Claude+Person joint GitHub commits, how can I personally contribute towards feelings of ownership?

Notion has leveraged ownership through customization for non-technical people very well, creating almost a love / hate relationship.

Perhaps it’s that Notion customization (and that era of personal wiki software) got so painful that people pivotted to stickers and other forms of exchange and computing customization.

There’s an art / ritual exchange project hiding here 💡

Paperclip opensourced today.

Notion x Claude Code with a demo published today for visual vibe coding and versioning.

Market is validating my thoughts faster than I can create - what to do about it; what’s a good honest fun USEFUL goal to have, that will make me happy and give me enough money to buy eletronics from Adafruit directly? lol

image

What if instead of corporate apps on our computers, we had projects with custom interfaces organized by function?

And that is what I’m spinning up. Right now, the primary interface is that I click app first.

But actually brain works with intention first.

The way I ended up with 849 Safari tabs open on my computer was that I’d have intentions, something to figure out and kick start the process with a search and leave it there to come back later.

Closing that tab means I’ve lost that intention.

Moving that intention onto dedicated software is currently awful.

image

Old: App/Media type first

VS Code

Google Chrome Tab with pinout

Mixed projects, working on 3 things at the same time

New: Function based

Image of pinout

Window with my code

Terminal to jump through

Human-AI Interaction ⭐️ 😮 Human-Computer Interaction ❌

Perhaps the new human-AI interface is me writing a free form text à la Morning Pages from the Artists Way and have that spin up answers with its own context and workspace.

Why this works

  • Each idea and thought I have has 4 different branching thoughts
  • My fingers are slower than my brain, which allows for thinking and developing thought.
  • I always find answers to my own questions by writing or speaking out loud.

  • Growing fear
  • Essay quality for AI native teenagers is declining. We want humans to learn. 40% of genZ struggling with handwritten communication.

Are we going to have masters programs called HAI (Human AI interaction) instead of HCI?

If we live in this speculative future where corporate apps are no longer the primary way to interact with the world.

Is the way to monetize this interest (i.e. a job or entrepreneurship) and not do a PhD - custom controllers? Are these the single purpose devices that I was talking about in my ITP application? They are. A tear sheds as I realize. Unclear if it’s from happiness from confirming my stances or sadness that I spent all this time away following the unknowns purely because they’re unknowns.

Great. I start a section in my notes app called ITP Lessons. The 3rd one. I realize I’ve learnt this before. My computing world is a dependency filled chaos.

On PhDs and what to do with my life

Tom mentioned being too deep in Electrical Engineering, as I stare at an Arduino Nano 33 IoT broken antenna and one from Seeed Studio and wonder what they do differently.

And then that I could do a PhD on these topics.

Subtext being that I should be either prioritizing other parts of the project OR commit to the bit and acknowledge that how I choose to spend my time doesn’t align with any capitalistic goals I may have.

💡

AAAAAA

Yesterday, I spent 4 hours helping a classmate on his project. He apologized profusely for taking my time. Indeed my time was taken, but I really enjoyed it (teaching).

In fact, I find myself not doing my own work to help someone with theirs very often.

Is this human nature, procrastination, fear of hard work or a genuine passion for passing on knowledge and empowering others?

AAAAAAAAAA

💡

AAAAAA

Fabri and I discussed “If anyone can 3D print their clothes, does that mean everyone’s clothes are suddenly more unique or more homogenous?” My answer is that it’s not about the options, but rather how many processes one has to stitch components together.

[ Reference: Kim Kardashian: Hollywood]

image

so putting these 3 things together…..

Entrepreneurship is what people do when they have a strong vision for how the world should work, new ideas frequently but no time to pursue them. So they delegate. Et voilá, this could be the dictionary definition of a company.

PhD is what people do when they wonder and have questions. And when they enjoy teaching the result of that search.

Googling is what people do when they wonder; and someone has already figured it out.

Book (writing) is what you do when you have a lot to say and want to explore it in detail.

It does take time. Which is why you typically do it to document a PhD.

Full time job is what you do if you want peace of mind and to be eligible to purchase a home in Portugal.

This is novel for me because thus far my personal philosophy on teaching is that you shouldn’t do it if that’s the only career outcome because that’s effectively perpetuating a Ponzi scheme. But what about when it feels like the only choice out of enjoyment? How does one distinguish?

I’d like to be heading towards organized systems for personal data that are private.

BUT much like in Fabri’s 3D clothing example, the thing that makes a tool exciting to use is the fact that I built it. So is customizing a dashboard enough for someone to feel ownership? Or do you need to be knowledgable on the inner workings to be able to cut data together?

I’ve spent years thinking about these systems, never realizing I myself was empowered to build them. And now that knowledge is compounding, and I have interesting ideas every 30 minutes which I feel the need to capture, natural language processing/AI + data structures can genuinely be an answer. Plus devices in the home to store + consume.

Is building that capture system a valid life choice? Is this a hobby or do I attempt to make tools around this into a career? DATA → Embedded Furniture and Wearables → How to build ownership and a collectivistic mindset in Fashion Tech → Personal Networks → Distributed knowledge → Centralized World Map → Data Infrastructures (but for a specific application)

Additionally, how much should I stick to my European Union values? How much AI should I use in my own building workflow?

To discuss with Tom

If future of computing is personal,

Each of us can too make their own controllers and devices.

But it’s expensive.

Either because you don’t know what you’re doing so you buy boards with more capabilities than you need or because you’re buying brand name components from places like Adafruit, with tutorials, good documentation, community oversight, forum monitoring.

Expensive is a barrier.

The open source mindset is to remove barriers for participation (in society) (and play?).

The way to make it cheap is to buy components from China / Ali Express ect.

To make custom controllers at a competitive price, eventually that’s the way. Although there is an american pcb manufacturer, for ex. But innovation + cheaper components is certainly happening there.

Maybe this is the mechanism inflation comes down once and for all. Is this line of thinking rooted in macro-economics?

So how

What’s Tom’s opinion about future of hardware and the kind of making that we’ve seen happening at ITP?

Society should reward with the available mechanisms the people who advanced it.

What do we consider advancement? Are the chinese people who took an italian + american open source innovation and made it cheaper (=accessible) also advancing society? Or is this an unwanted externality from open source?

How do I square these values with EU competitiveness strategy?

If we vote with our dollars, then I should be buying from Adafruit or manufacturer’s site. Speak (and buy) your futures into existence.

#TODO Would be fun to set up an eletronics library on the street / like community fridge or Little Books OOOOOOR community server with a devboard with all kinds of sensors where the data is stored locally but neighbours can SSH into it!

(I like SSH as a concept bc I like the terminal but realistically this is what a web served dashboard is, so actually this doesn’t make sense).

If…………………. hardware is cheapest (and most innovative) coming from China by 2 to 10x multiples;

……………..research in unis is defunded;

………… software is dead as a new career choice;

Then………………… ????????????????????????????

Feels like ITP students have the profile and skill set that global systems are begging for; yet past and current generations feel directionless and poorly compensated.

Lines between roles are getting blurred (referencing Harvard paper on people doing more work with AI, not less), and in a program where they were blurred to begin with, and that brands itself on end of career outcomes, there’s definitely something to be figured out. And the entrepreneurship solution unfortunately definitionally doesn’t work for ITP students unless you go really big.

To quote Jeff Feddersen, we just make art and study ethics. But what’s the feasible solution for 98% of society? and 100% of ITP Students?

Full Stack Builder

Microsoft’s solution: the Full Stack Builder role combining those of product teams (product manager, designer, front end engineer, backend engineer) & Fusion Software Development.

“To make full-stack development a reality inside any given organization, Microsoft has said that there will need to be a degree of initial investment into engineering systems and context. This, then, would be the scaffolding. Redmond suggests that new applications will emerge that are architected to support natural language development, augmentation and modification.”

My criticism to this is that a team brings diverse perspectives; people to question if this is what we should even be building; and less burnout / enjoyment of work through collaboration.

Not to mention the economic impacts of running small businesses person companies. Who’s the customer for all of them? Wouldn’t they be duplicated? And if something is widely available, it loses economic value. If it loses economic value → no profit. No profit → no jobs. No jobs → who’s paying AI tokens? (Current answer: big enterprise contracts; individual consumers at 20$ supply training data).

But in this scenario big enterprises are no longer so big (see layoffs & average hiring age being 45). Therefore, question remains open.

→ People would then rally around industries / specific challenges organized locally, perhaps, even though work can be done globally. But it’s unclear to me whether there are actually enough challenges to go around and that people outside of technology are empowered to pursue them.

I see the (architectural) light 🕯️

  • My VPS can host my data; JSON or a DB.
    • Make that data available through an API.
      • FastAPI ! :D
    • Opposite to microcontroller/device data (bc hard to upload firmware) - in a VPS, data structure should be handled on DB side.
      • That’s the architecture that fulfills AI / Agentic spirit. The way the (sad) future of creating our own tools with AI becomes a semi happy reality.
        • Have a database with an API that has the personal data you need for any given project; fetch it and build front end with Claude Code + Figma MCP or Figma Make project into Claude Code or Claude Code /design skill.
  • The front end can be hosted through Vercel as a client side only application. Free.
    • HTTP GET /fetch/table_name/new bla ID
  • Any physical devices can fetch that when connected to a network with WiFi.
💡

I now see that in trying to “simplify” and have my own computer not be a part of the architecture at all, I did something fun but that’s not scalable giving $$ Digital Ocean limits. Web Servers can be hosted for free. Waste of resources to do it inside a VPS.

Therefore, the premise of the question of how to preview web server code when editing VPS files doesn’t make much sense. WHICH IS WHY WE NEED PROJECT/FUNCTION BASED OS INTERFACES. Because I can’t remember every tool I used for a given task.

Apple is probably already building this. Is there a point in trying?

image

Architecture for Tab Graveyard project: Electron or SwiftUI app? Connected to a central server?

Yep but also doesn’t matter.

The tab list should be uploaded directly onto VPS and served from there.

Week 6: Questions for Tom’s office hours

  1. MQTT won't work through Cloudflare's proxy. So now my VPS’s IP is exposed. Should I care?
    1. Set up a firewall for any port I’m not using.
    2. Connecting MQTT request via Web Sockets.
    3. Set up MQTT connections as MQTT secure.
      • Set up an SSH key for MQTT;
      • make sure that all my clients
      • Wifi SSL client is old wifi, everything else is the same.
      • On the client side, you can use everything.
        • Secure certificate.
      • DNS is a system of rumours.
      • Every local domain server has to get new records. It would be a lot of traffic.
      • DNS records sometimes are available through one and not other.
  2. ESP32-Wifi-Depth project - changing router to wpa2 multimodal. Any security vulnerabilities?
    1. If yes, are there any microcontrollers that could do WPA3 and CSI?

WIFI issues

  • Desktop Client MQTT Client to see if I can connect to broker
    • Look at Microcontroller client
  1. (Thesis) Wifi network signal strength is directional. Any ways around this?
  2. Platforms for wireframing hardware? Workflows within a VPS.
  3. Could I SSH into my devices? What OS would they need to run? Base requirements? Linux
    1. Thomas K Connecting to a Terminal Server (SSH) on iPhone or iPadThomas K Connecting to a Terminal Server (SSH) on iPhone or iPad
    2. It would be so fun to try jailbreaking into my old iPhone

2 radios separated by 1.5m. Someone at ITP tried it and didn’t work so well.

Antenna close

I don’t have antenna in my set up.

Design devices in such a way that they get connected/triggered near each other.

Can I design a PCB and choose direction?

WiFi shouldn’t

Tom’s solutions:

Use NFC; NFC NFC

NFC can ask the device which protocol it needs.

Exist Gappleted; AirPlay.

What does

Network Topology (for Dummies?™️)

VPS would be on the same network from the same provider.

MQTT ran on a VPS.

Dis

VPS + Tunnel + Device (Raspberry Pi) ———- (Cloudflare or nGrok).

Write a separate client Node.js script;

Gave a different Cortex;

They go through same MQTT

TODO

  • My ESP32 needs the WiFi antenna.
  • Need to source an NFC connection. Does PI have it?
  • Add firewall to block unused ports.

Office Hours with Fabri - Week 6 - March 4th, 2026

Advice → Save time in measuring and being precise in hyper optimal organizing components inside enclosures; and learn how to make PCBs. A new argument for how I’ve been wasting TIME™️ and ENERGY™️ at ITP. Get tiny terminal blocks if needed.

Wires

Crimping tools remove need for twisting Stringy Wire, but they’re a lot of work.

Solid core wire eventually breaks when bent.

Shop has 22AW gauge.

Soldering

Warm the pad and wire first so that it transfers.

Coat stringy wire with solder using a larger pen.

Flux lowers temp at which solder melts → releases fumes.

ITP solder has flux in it already.

TBD: how/why I burned my personal soddering pen tip.

Week 6 - Device 1 - Environmental Data with MQTT

Room Magnetic Pulse
http://living.ines.systems/

image

[ Add my experiments around the ESP32 for Body Pose; and with Seeed Studio Display]

MQTT

Instead of sending a message every ~5ms, could use the ArduinoMqttClientTouchReadESP32.ino example to send data based on a certain threshold only. Is there any downside vs sending message based on time?

Running on VPS

image

Wifi/DensePose experiment

I found a project that uses an ESP32-S3 (or ideally more) and a wifi router to determine body pose, breathing, heartbeat, motion and presence within 5m of the Wifi router.

I was able to set up the Docker Container but the ESP32-S3 couldn’t connect to my home router, due to it being WPA3. I wasn’t able to test with a personal hotspot because I changed hotspot names, but that might have worked.

Question: Does switching my home router to WPA2/WPA3 mixed mode have any unintended consequences?

Links

GitHub RuView/docs/user-guide.md at main · ruvnet/RuViewGitHub RuView/docs/user-guide.md at main · ruvnet/RuView

Embed GitHubEmbed GitHub

“The ESP32 nodes stream binary CSI frames over UDP to port 5005. See Hardware Setup for flashing instructions.”

Next steps and existential programmatic questions and interesting finds and thought ships (trains are too slow for this analogy ha)

  1. ArduinoMqttClientWithWill introduces MQTT Last Will and Testament (LWT). It lets the broker automatically publish a "device offline" message if sensor drops unexpectedly, useful for a long-running room monitor meant to be stationary and unmonitored.
  2. ✅ How to RTC without a physical module extra module with battery? API works! NTP (Network Time Protocol); ESP32 fetches real clock time from the internet right after WiFi connects. Built into the ESP32, no extra library needed.
  3. Currently editing on VS code on a local / Github folder and then copying into VPS. Wonder if there’s a better way? Feels silly and prone to confusion. OOOOR could be automated somehow. By creating a Git system for my personal computer and my VPS? Or making a little alias to automatically copy/replace files once edits have been done.
  4. My computer:

    scp script.js ines@living.ines.systems:/tmp/

    VPS:

    ssh ines@living.ines.systems sudo cp /tmp/script.js /var/www/html/

    Find it fascinating that I don’t need to restart any PID on my VPS after changing the files… Is it because it’s JS specifically? or a browser client? Can I set any server up to update automatically after copying a file into it?

    I remember learning programing (Ruby on Rails) that server side data would be served once and not be able to be changed through user action. But I suppose this is not true in applications. One could have the PID just running in the background, VPS never shuts, and while the same data wouldn’t change, we could send requests to swap out just portions of it. I suppose that’s what React is. It was exciting because otherwise web pages were done to be updated/served in full. But it’s not that it’s not possible to develop such arquitecture.

    This modular thinking would serve AI contexts well in interfaces. RE Anthropic Hackathon

    Is there a test mode or do I always just ship to “production”?

    Serving to localhost wouldn’t be local to me — not same network. So… I would be deploying to a subdomain or another test website setup done for this purpose. But because I have no users or important DB/Data, then I don’t have to care…

  5. Could I include compiling on the Arduino IDE as part of some end-of-bug-fixing script? Or only for CircuitPython compiling?
  6. Add script to check different WiFi networks for connectivity

In class demo issue: SparkFun’s GPIO12 was wrongfully connected. It's a strapping pin that controls flash voltage. If it's HIGH at boot, flash runs at 1.8V instead of 3.3V. The flash chip needed 3.3V to write properly.

Solid enclosures and circuits; next steps

  1. Protoboard: Breadboard wire is enemy #1 of small devices. Purchased very very tiny terminal blocks.
  2. Add USB port opening.
  3. Test how exposed magnometer needs to be to be functional.
    1. EG. very thin layer of PLA, very little in-fill in that specific section? Do I need to edit this in G-Code or does my slicer have options?
  4. Learn CAD methods for twist locks and clasps. Enclosures need to be open and repairable. Screws are sometimes conceptually... screwed to remove.
  5. GrabCAD for 3D models of the eletronics and then extrude those out of the enclosure instead of modelling from scratch.
  6. Add LIPO breakout board
    1. Can they take any voltage power source?
image

Interface

  1. Display: What’s useful to know when debugging?
  2. PWM an LED to show you if it’s connected.
    1. Aram has very small LEDs.
  3. Use color associations and pattern recognition wisely.
  4. Work towards reducing number of buttons.
  • Audio is useful for events (EG. temperature reaching X; print is ready).

Data / sensor selection next steps

I’m still fundamentally missing data outcomes that I find exciting.

Options that require purchasing/sourcing

  1. Get 3 extra PIRs + XIAO ESP32 and place them on individual room doors.
  2. Array of PIRs but not in the individual room doors, instead facing different directions on the table center piece or in key spots of the apartment.
  3. Get a magnometer with more range.
  4. Get a microphone that only communicates to MQTT whether there’s sound and at what intensity. No sound files transmitted for privacy. Sound is a huge hallmark of motion and aliveness.
    1. Can we handle privacy for sound at the hardware level, instead of software? Is that just a very crappy microphone?

Options with my existing hardware

  1. Second biggest hallmark of motion and aliveness is… motion. Get Wifi Depth Pose to work since I have hardware already enough to triangulate multiple people. Need to change my home router to multimodal WPA2/WPA3. Data includes body pose, breathing, heartbeat, motion and presence.
    1. Possible limitations around having the router not in the living room. Solve with 3rd ESP32-S3 (use Rev TFT board).
    2. Q: If done with Meshtastic, could we look at body pose of…. a whole city? 😮 !!!!
  2. Put my 8 VLX distance sensors to work and form a “sensing” cage to map out the space in Three JS.

Without changing anything

  1. Can use the PIR, based on clusters of times when it gets activated to see activity.

In Class Notes

Can we detect physical motion / data activity of their laptops without external data companies?

I do have administrative access to my router. Makes me think how families need to have a bond of trust and boundaries and who’s in control of the network, has access & information and how often trust is not broken, not due to trust itself but through lack of access to knowledge.

Tom has never heard of an IoT network. But that ‘smells’ a lot like my thesis project. Could we define multiple devices connected in isolation as an IoT network? Would such thing be useful? Why not?

Fabri = visualization of signal strenght.

Wifi Mapping is tough to do, because it doesn’t exist within a space, but there’s still bounds.

How do you encourage people to hunt for the data you need?

NFC tag to receive something, like a treasure hunt.

The network gives, the network takes.

Wifi network signal strength is directional.

#TODO Talk more to Fabri about this.

If you have 4, you could team up in teams of 2, you could follow an existing pattern and complete a map that you visually see on the display and maybe even find another.

People finding a way back to each other. Expand the world.

Good mindset = Figure out what piece of data you need and is missing and design a gamified experience that helps you get it.

cat data.json ||

💡

!! Arquitecture wise, this is precisely what I’ve been wanting to set up as my home / remote access devboard + connected to Claude Code to run experiments from out of home on my phone. Answering those “I wonder if” questions for proofs of concept and ideas I have when I’m out in the city. Only question missing would be how to upload firmware to the ESP32 remotely. If not possible because no OS, then a workflow would be to: 1. Collect any data possible from Arduino, all packaged nicely into a JSON file with little to no treatment. 2. In the same way that I have setup certain branches to deploy automatically to Vercel after commits, could I set up something that: a) deploys directly new script / client side files to my Virtual Private Server? but that would require giving an external cloud service SSH / Password access to my VPS….. b) Or setting up MQTT (if message = do X) / API / use existing one that picks up index.html code and such, and rewrites or replaces file + restarts servers. - Can MQTT Broker take in 300 lines of code or is it just values and small json lines? c) Essentially would need to have a different server other than my VPS send it code. And make sure all systems are incredibly siloed and backed up so that hacks / adversarial attacks don’t have real impact. - Scratch the whole idea and just have an SMS service that texts me results of my experiment. Or fulfill AI’s supposed purpose for society and work and think less instead of strategizing ways of doing it from more places 🙃

Next class - due

  1. Actual assignment
  2. Collect data for a week.
  3. Data analysis
  4. Keep working on enclosures with heat inserts
    1. Noah starts with a reference to trace out.
  5. Add diagram here

Week 4 and 5 - Device 1

My initial goal was to detect the (electromagnetic) life of a room by picking up magnetic field disturbances from nearby electronics (phones, laptops, etc.), but through testing I realized the range is very small (2 to 10cm) and there’s too much noise for this to be appropriate. I’m now layering sensors for an ambient environment logger that builds a continuous, multi-dimensional portrait of a room over time. It makes visible what is normally invisible: the electromagnetic texture of a space, the presence or absence of people, the rhythms of activity and rest that define how a room actually lives and the people who occupy it. The output should be an art piece inspired by Daniel Canogar’s Billow III (2020). I’m also hoping to scale from there some ‘living’ furniture pieces that trigger local AI workflows, but this in all likelihood will take form after graduation.

image
# Check IP Address and update Arduino sketch
ipconfig getifaddr en0

# Change

# Terminal 1: receives ESP32 data
nc -l 8080 | tee -a log.json &
#	 -a (append) to preserve previous data across reconnects.

# Terminal 2: serves the dashboard
python3 -m http.server 3000

{"device":"RoomSensor","ts":1305264,"mag":{"x":16.00,"y":4.00,"z":-9.00,"mag":18.79},"pir":{"raw":0,"motion":false}}

Could use a Web Socket.

V1

image

Eletronics in my project

  • Sparkfun ESP32 Thing Plus (USB-C)
  • Waveshare BMM150 3-Axis Magnetometer Sensor
  • Datasheet

  • SparkFun OpenPIR. Will mount this or a distance sensor facing a doorway or desk area in a wirelessly connected separate device.
image

Next steps

  • Attach to virtual server and leave it at home
  • Collect data over time
  • Give meaning to PIR data
  • Establish baseline for magnetometer

Week 3

Tech vs Regulation

A lot of my questions have been developing around internet ethics and what are strategy decisions - from regulators or private companies - and technical limitations. I did not realize how much of what’s possible is almost entirely up to regulation, physical control of server location, App Store locations and internal checks and balances.

Reece Rogers TikTok Is Now Collecting Even More Data About Its Users. Here Are the 3 Biggest ChangesReece Rogers TikTok Is Now Collecting Even More Data About Its Users. Here Are the 3 Biggest Changes

Something interesting to understand would be exactly where the tension is between regulation and physical location. Where location is pulled from will depend on the apps architecture and the update upload pipeline created by the App Store.

  • Having an EU registered device and App Store linked to EU billing, certain features or updates aren’t available for my region;
  • Privacy policy for TikTok is set as Canadian soil because I signed up on Canadian soil;
  • Same privacy policy says that I’m subject to the privacy policy of the country I’m using the app from, yet it doesn’t make the US privacy policy available to me as user.
  • Finally, I’m barred from accessing a number of services and apps (from very trivial ones to others like Venmo) unless I switch my devices’ region

What I’m realizing is that this really has nothing to do with technicals, but everything to do with how carefully privacy laws are written, which likely does not include cross nation litigation to cover the kind of global movement we see today. Borders seem to be very much in effect and any movement of data or people is all a product of cooperation. It would be worth understanding what can be done in this space and more on the politics of software.

Resource → Electronic Privacy Information Center (Washington-based nonprofit)

Virtual Private Server

Created with Ubuntu OS (Q: how does it relate to Linux? How many are shared commands?), and installed ufw firewall - which means I need to remember to enable certain ports if I want to run multiple servers off of it other than on port 8080 and 8081, blocking incoming traffic other than on certain ports, net-tools, ifconfig (state of network interfaces), SSH key authentication only. To know

image
  • Port 8081, typically used by the p5.serialserver
  • Package installations are done like so sudo apt install nodejs
  • Shutdown via sudo poweroff or logout and leave it running with logout
    • When I quit the terminal session with ^C, it’s the same as logout is done (Q: is it?). The differences might become more material when there are multiple users or perhaps multiple instances of the terminal accessed from the same local machine.
  • SSH = Secure Shell = Communication Protocol

Rabbit hole of questions semi solved through writing

I don’t want to have to check the droplet’s IP address every time (or else, how do usually devs do it?) so options are:

  • SSH config alias - local only, like a keyboard replacement shortcut.
  • Replacing hostname with an actual machine name as such ssh username@myserver.local or ssh username@myserver.com
    • Off topic Q: Does this provide any insight on how email is architecture? Is each individual inbox a server…? Or more like 1 shared server with database tables?

(Resolved) What I’m not fully getting is why the hostname setup with DigitalOcean isn’t valid to SSH into the server as well and therefore, extra steps are necessary. Likely it makes sense because the hostname from DigitalOcean is only revealed to our local computer once I’m granted access to the server. Since we haven’t yet registered a domain name and created a CDN (?) DNS record for it.

CDN (Content Delivery Network) = Fast delivery network; copies our data to other/more servers worldwide for faster access - instead of for example, just being on NY 2 Datacenter.

(Resolved) I’m recalling some trouble around this when I was setting up a Raspberry Pi and changed networks from home to Sandbox, but can’t pin point exactly what the conditions were since now it makes perfect sense to me why the droplet has a hostname on virtual machine side, but it won't resolve unless DNS (Domain Name System = Internet's phone book) is set up.

Perhaps it was because ssh username@myserver.local is local to the network itself and not my local machine? Bingo.

But I still can’t set this kind of access up for a virtual machine. Raspberry Pi wasn’t a virtual machine - it was just another machine, first with a wired connection and then on the same network as my local machine.

(Unresolved) I suppose this puts into perspective what we mean when we say local machine. Seems like it’s always relative - but is it about physical location and any machine being used to access another is always called the local one? Or is it about being on different networks?

  1. In my previous example, referring to my MacBook as the local machine makes little sense in the context of a Raspberry Pi wired or with wireless access to internet on the same network. From the network’s perspective, both are local and mDNS is available to create custom hostnames.
    1. But if I’m accessing that same RaspberryPi from my Macbook, then would professionals in the field refer to the Macbook as the local machine as well?
  2. (Resolved) When it’s Macbook versus DigitalOcean droplet / server, then indeed the Macbook would be my local machine because it’s on my local network (local as in, the access point (router) with most proximity to me physically) BUT also in relation to the droplet which is accessible on the internet and on a different network (Q). Therefore no .local addresses through multicast DNS. Because there’s something “better” ….. just regular DNS.
    1. Side unresolved question: This brings up the question of what do we call intersections of networks - perhaps there’s no need and we’re simply making a request to a separate entity and that’s that.
    2. But… in a world where my home internet provider and the NY Datacenter 2 are the same, and presumably have routers/nodes within range of each other, what would be keeping us from being on the same network? Would it just be corporate decision making to have separation of concerns, access limitations and nothing technical?

Conclusion

Not wanting to check (or memorize) the VPS’s IP address every time is precisely the problem that led to the creation of domain names. So the only way for me not to have to copy the IP address everytime is to get a domain name or set up a silly alias.

On domain names for static sites and server side sites

CNET AI.com Launches After $70 Million Sale and a Super Bowl DebutCNET AI.com Launches After $70 Million Sale and a Super Bowl Debut
This is timely as the most expensive domain purchase just took place for ai.com.

(Resolved) So when we’re paying for domain names, is it because domain name companies have scanned the internet to find all interesting unregistered domains, then proceeded to register them with Cann themselves and only giving up their registration details (or whatever iCann holds) in exchange for money (also known as making a sale)? YES.

(Resolved) It’s not a sale, it’s rental. Domain Name company still has control over domain registration - they just point an IP address that you provide them with to your chosen domain temporarily. & iCann doesn’t hold actually anything 😭

Or is it because domain name companies bundle it up with other services (like CDN and serving your client only files) and with some marketing sparkle, they package it up for the non-technical folks? YES. depends on the company and what’s their positioning in the market.

Hosting SPAs vs databases

Why does anything with a database/server side fetching cost money to host but client-side only / Single Page Applications / static sites files can be served at presumably no cost?

My single page application hosted with Vercel, domain name 10$/year, free otherwise has files around 1.5GB, with a max of 100mb each.

For another site, I have an PostgreSQL database hosted on Heroku, that I pay 12$/month for but that has ~300mb worth in files.

If all computing is physical, then what kind of services explain this kind of difference - beyond how pricing is structured and that the server side files are more… protected?

Some answers might be in setting up encryption, security, backups, logs ect. Apart from perhaps encryption, aren’t all these things already available as packages for free? Is it just that people don’t want to set them up or is there anything else that I’m missing?

image

Eg. it was easy&free for me to register trial.space as a domain but there’s additional setup

image
image

Learning about networks has shaken up has brought up questions on limitations I’ve experienced over the past 2+ years of learning to code - since I built my computing mental map from the industry, policy and library side, I’m trying to connect with the other technical side and realize a lot of decisions have a product foundation. I’m on my way to the slope of enlightenment…

image

Resources

Networks at ITP Setting Up a Firewall on a Linux DeviceNetworks at ITP Setting Up a Firewall on a Linux Device

Networks at ITP Setting Up a Virtual HostNetworks at ITP Setting Up a Virtual Host

For an upcoming rabbit hole,

Look at open source vector embeddings or DIY options vs Digital Ocean’s offering.

image

Week 2

Final Dashboard

I wanted to use the Accelerometer to create a Dinosaur Game style interaction from Google Chrome’s 404 page in my dashboard. From there I ended up, using it to interact with an old sketch.

Next up would be to increase the communication rate and make the “controller” actually wireless and battery powered.

image
image

When I overwork my computer, something interesting has been happening: it gets stuck in a keyboard position but it’s a software issue.

Scan Networks Sketch Serial Monitor:

Please upgrade the firmware
MAC: 8C:AA:B5:8A:C9:04
Scanning available networks...
** Scan Networks **
number of available networks:2
0) MyAltice 540c8b	Signal: -83 dBm	Encryption: WPA2
1) crab	Signal: -94 dBm	Encryption: WPA2

Running WiFiTCPClient Logger

image

The Arduino I was using mysteriously lost its WiFi antenna.

Q: is there a reason to be replacing instead of using the value directly?

Q ✅

Serial Monitor showed:

connecting
192.168.1.96
8080

When I closed Serial Monitor and opened nc -klw 2 8080, the expected messages of {"device": "first", "AccX": 0.22, "AccY": -0.96, "AccZ": 0.28} started rolling in. Upon closing Serial Monitor, there seemed to be a glitch.

Why? I expected to see the same output on both.

image

Answer:

image

Arduino was stuck in a loop because client.connect() kept failing (no server to connect to). Once netcat was running, the connection succeeded, moving past the return to actually read sensors and send data.

To send output of netcat server on port 8080 to log.json, as well as keep sending it to terminal window and keep it running in the background: nc -l 8080 | tee log.json &

image

Now logging port 8080 data onto log.json, leave it running in the background and spin a web server on port assigned by terminal (?) - 8000

nc -l 8080 >> log.json & python3 -m http.server

image

Useful Commands

➜  wifi-dashboard echo "# wifi-dashboard" >> README.md
➜  wifi-dashboard echo "# wifi-dashboard" >> .gitignore
➜  wifi-dashboard echo "arduino_secrets.h" >> .gitignore

nano filename # Edit directly 
killall nc # kill all netcat processes (were all competing for same port)

#TODO Add database of useful commands, shortcuts, aliases? categorized by program.

Making the dashboard interesting

As I know roughly what I want to be seeing, but it would take me more time than I can dedicate, I decided to try and prompt my way into it. To avoid losing anything, I created a GitHub repo.

❓

I did some other fixes in between manually, particularly in regards to timing.

Prompt

I now want to take these barebones HTML Pages and turn them into something visually more interesting. I want to create 3 divs side by side.

1 should show the accelerometer data raw exactly as it comes in.

The second div should be a 3D canvas, either done with the Canvas Browser API or with Three JS. This will require some data processing as I want to use the X, Y; Z coordinates to trace a path. The latest data to come in should have the brightest color and it should diminish in brightness as we see older and older data. Let's have a maximum of 10 data points at any given time being visualized.

The 3rd one for now will be a placeholder.

When possible implement responsive UI.

Result without further changes

image

Prompt #2

❓

I wanted to use the accelerometer data to interact with something I’ve previously done for one of my websites - https://www.digipeasy.studio. Also have been wanting to explore how much of customization can be done with Claude Code, based on creative direction existing in other projects. It did quite well in one prompt, including copying my existing color codes and imagery.

On desktop, panel 1 will now be above panel 2, to create more room for panel 2.

/Users/ineslucas/code/ineslucas/creative-toolbox/src/pages/SkillsTags.js

For the 3rd panel, you're going to recreate my SkillsTags.js page. Copy the relevant assets from my Creative Toolbox project, including colors and my picture.

I also want you to look at the kind of styling, colors and fonts I'm using in that project and bring those over.

Do not change the tech stack unless you have my explicit permission. I want to keep this as simple as possible.

image

Prompt #3

Make the 3JS container occupy the full height of the container and have the animation be on or off via a toggle. Default is for animation to be off. Add orbit controls.

In the desktop version, now panel 1 and 2 only occupy 30% of the screen width.

On Panel 3:

  1. Instead of spinning the balls into the ecosystem through the mouse, let's have that happen on load.
  2. Make them bigger and let's have 30% less of them.
  3. Add one in this color #F57935.
  4. Now I want to use the x and y values of the accelerometer to move the #F57935 colored ball. Of course it should represent the movement I'm doing in reality.
image

Week 1

Goals for class are around wanting to contribute towards the evolution of small form factor personal devices into what I’ve been calling single purpose hardware if we prioritize personalization and user satisfaction instead of ad driven pricing models.

Electronic devices in my routines

Personal

  • Phone
  • Laptop
  • Wireless Headphones
  • Two-factor authentication prompts
  • Go Pro & live streaming into app

Home Devices

  • Latch Building Door Lock (Bluetooth app)
  • Alexa as a speaker and alarm clock with music :(
  • Smart bulbs
  • Air Purifier
  • 3D Printer
  • Wifi Router
  • Smart TV
  • K-beauty LED Tech Device (bluetooth connection to phone app?)
  • Photo printer (Wifi connection into phone app)
  • Label Maker (not a connected device)

On the go

  • MTA Tap to Pay or POS Keypad
  • Passport Scanner at the airport
  • Buzzer to signal restaurant meal is ready
  • Receipt Printers
  • Motion Sensors

On campus

  • NYU Card to enter building
  • System determines # of people on campus setting general AC temp :( + what does that system look like and how does it ‘network’ floor to floor differently than others?
  • Charger Locker by the ER

Some affecting my environment indirectly

….. 🤔

Connected Devices 

Examples include Arduino to a web server or laptops talking to each other's laptops. IoT is the new connected devices.

Operating Systems 

Unix & Linux = POSIX operating systems with similar commands and structure. MacOS is now a Unix OS.

Networking Infrastructure

  • VPN = allows you to be in one real network while you're also in the private one
  • Virtual Private Server: Instance of an operating system within an operating system = containers. Each instance won't affect other people's instances
❓

How is this different from Docker?

Network Interfaces 

Laptop has 3 network layers: WiFi, Bluetooth, Ethernet

Geographies of the internet: OSI Model: Please do not throw sausage pizza away

  • Physical layer - What physical medium are you transmitting on?
  • Datalink layer - What's your physical address (MAC address), regardless of which network you're on?
  • Network layer - What's your network address (IP address)? How do you connect to other networks?
  • Transport layer - How are you sending data packets? Should the receiver acknowledge them?
  • Session layer - How do you say hello and goodbye?
  • Presentation layer - How is the data formatted and/or encrypted? (e.g., HTML)
  • Application layer - What are you doing with the data transmitted or received?

Key points

With OSI model, web developers know a lot about presentation and application layer.

MAC address is unique to each computer.

IP (or Inet) number changes everytime you connect to a network. As long as you have an address.

Network Topologies

Random Networks Links between nodes are placed randomly. Messages travel hop by hop to reach distant nodes (distributed network).

Centralized Networks All nodes connect to one central node (star shape). Without the central node, the network is gone.

Decentralized Networks  Essentially comprised of hubs, each with a central node. Hubs are linked together. Removal of one hub only affects nodes dependent on it.

The Internet Structure

  • No single central router
  • Network providers connect to each other through multiple links
  • Greater link density = more possible paths = more reliable service
  • Complete networks connect every node to every other node, requiring (n²-n)/2 links

Small World Networks

  • Strong ties to nearest neighbors, weak ties across larger network
  • Weak ties are crucial for connecting the larger network
  • Example: finding jobs through acquaintances rather than close friends

Visual Trace Route:

Stefan Sundin Traceroute mapperStefan Sundin Traceroute mapper

Network Infrastructure

Content Delivery Network = Cloudflare

Autonomous Systems Networks of networks joined using Border Gateway Protocol (BGP). Major ISPs maintain these routers.

IP Addresses

  • IPv4: 4 bytes long
  • Public IP addresses are unique on the internet
  • Private IP address ranges: 10.0.0.0, 172.16.0.0, 192.168.0.0
  • Routers have both public and private IP addresses, acting as gateways

Address Assignment

  • MAC addresses: Licensed from IEEE, 6 bytes (first 3 = OUI, last 3 = unique device ID)
  • IP addresses: Managed by IANA through Regional Internet Registries (RIRs)
  • ARP (Address Resolution Protocol): Associates MAC address with IP address

Interface types GUI (the p5 editor for example) vs Text Interfaces (Command line tools?).

Command Line Tools

❓

I’m trying to figure out ways to use AI to standardize format of my notes. Original version lives here. Reformatted clean version is below.

‣

Command Line Tools

  • nslookup tigon.net - to see IP address to any given website.
  • ifconfig en0 - The developer way
  • traceroute tigoe.net
  • ‣
    Describes network touchpoints or nodes we go through. Network providers try to route your request through the most optimal way to serve your data. This also tells us who has information about our traffic and potentially influences speed.
    image
  • clear - to end instance of any given terminal.
  • ls -l - ls with details
    • shows permissions (eg. drwxr-xr-x, which is execute, read, write permissions)
  • cat filename - to see what’s inside
    • stands for concatenate
  • ls /dev/cu.* or ls /dev/ - to see serial ports available.
    • Serial ports end up being almost files so they can be accessed through cat =
  • cat /dev/cu.usbmodem101
    • with this you get a stream of the data being transferred via the port.
    • we know the port name from the Arduino IDE or by running difs on the list after connecting Arduino.
    • Serial Port gets created after plugging in Arduino
  • Pipe it = Redirect the output of a command to another - so execute the serial port output somewhere else
    • cat /dev/cu.usbmodem101 >> log.txt
      • There’s lots of automation possible here.
      • Now the output of the serial port is being saved for the first time.
    • cat /dev/cu.usbmodem101 >> log.txt &
      • & ensures process is running in the background
    • cat myfile.txt | grep Velux
      • grep looks up the word Velux in the file myfile.txt
  • ps - lists all processes we have running.
  • kill process number - kills a certain process.
  • cat *.txt
    • opens content of all txt files
  • nc tigoe.net 80
    • Get /
    • netcat = better program to list files
    • port 80
    • net cat goes over the net and cat only works locally
  • ls *.txt
    • lists all files with .txt extension
    • * = all files
  • nc -nklw 2 80
    • l means listen
    • w means wait timeout
  • man nc
    • the manual / helpsession

Curl is a full on tool.

To connect to a server, we use the HTTP protocol

  • we connect on any given port
  • Request verb (get, post) to a specific path.
nc -l 80
/get

python3 -m http.server 80
	# To serve 

10.20.54.224

Network Diagnostics

nslookup tigoe.net              # See IP address for any website
ifconfig en0                    # The developer way to check network config
traceroute tigoe.net            # Shows network touchpoints/nodes
                                # Reveals who has info about our traffic

File Management

clear                           # End terminal instance
ls -l                          # List with details (shows permissions like drwxr-xr-x)
cat filename                    # See file contents (stands for concatenate)
cat *.txt                      # Open all txt files
ls *.txt                       # List all txt files

Serial Port Access

ls /dev/cu.*                   # See available serial ports
ls /dev/                       # Alternative way
cat /dev/cu.usbmodem101        # Stream data from serial port
                               # Port name from Arduino IDE or by running diff
                               # Serial port created after plugging in Arduino

Piping & Background Processes

cat /dev/cu.usbmodem101 >> log.txt     # Redirect output to file
cat /dev/cu.usbmodem101 >> log.txt &   # Run in background with &
cat myfile.txt | grep Velux            # Search for "Velux" in file

Process Management

ps                             # List all running processes
kill process_number            # Kill a specific process

Network Tools

nc tigoe.net 80                # Netcat - works over network (vs cat locally)
                               # Port 80
nc -nklw 2 80                  # l=listen, w=wait timeout
man nc                         # Manual/help

HTTP Server

nc -l 80                       # Listen on port 80
/get                           # Request verb

python3 -m http.server 80      # Serve HTTP on port 80
# Example IP: 10.20.54.224

HTTP Protocol

To connect to a server, we use the HTTP protocol:

  • Connect on any given port
  • Use request verbs (GET, POST) to a specific path

Curl Full-featured tool for HTTP requests

References + Links

https://tigoe.nethttps://tigoe.net
https://tigoe.net
Geography of the Internet (Network Types & internet’s structure at a high level) 📝Geography of the Internet (Network Types & internet’s structure at a high level) 📝
Geography of the Internet (Network Types & internet’s structure at a high level) 📝
Class Site & SyllabusClass Site & Syllabus
Class Site & Syllabus
https://tigoe.github.iohttps://tigoe.github.io
https://tigoe.github.io
Networks & Hubs / Small world: Something Strange Happens When You Trace How Connected We AreNetworks & Hubs / Small world: Something Strange Happens When You Trace How Connected We Are
Networks & Hubs / Small world: Something Strange Happens When You Trace How Connected We Are
Networks @ ITP (glossary)Networks @ ITP (glossary)
Networks @ ITP (glossary)
The House That Spied On MeThe House That Spied On Me
The House That Spied On Me
Tools, Platforms & Guides (see cmd line help)Tools, Platforms & Guides (see cmd line help)
Tools, Platforms & Guides (see cmd line help)
Tools for Connected DevicesTools for Connected Devices
Tools for Connected Devices
Connecting a microcontroller via TCP to netcat
Marc Weiser, The Computer for the 21st Century (Scientific American, 1991)Marc Weiser, 
Marc Weiser, The Computer for the 21st Century (Scientific American, 1991)
The Coming Age of Calm TechThe Coming Age of Calm Tech
The Coming Age of Calm Tech
Ubiquitous Computing Demonstration using Tabs, Pads and Boards from 1988Ubiquitous Computing Demonstration using Tabs, Pads and Boards from 1988
Ubiquitous Computing Demonstration using Tabs, Pads and Boards from 1988
Introduction to BLE by Tom Igoe (Week 7) HAS WRITTEN CONTENTIntroduction to BLE by Tom Igoe (Week 7) HAS WRITTEN CONTENT
Introduction to BLE by Tom Igoe (Week 7) HAS WRITTEN CONTENT
MQTT Examples Arduino ClientsMQTT Examples Arduino Clients
MQTT Examples Arduino Clients
Second BrainSecond Brain
Second Brain
Can you improve air quality in your home? Indoor sensors track their daily life. [Week 3 reading]Can you improve air quality in your home? Indoor sensors track their daily life. [Week 3 reading]
Can you improve air quality in your home? Indoor sensors track their daily life. [Week 3 reading]
Hardware-esque UIHardware-esque UI
Hardware-esque UI
STM32 devices to Wifi with MQTTSTM32 devices to Wifi with MQTT
STM32 devices to Wifi with MQTT
Jingwen Zhu
/*
  Four line static file server
  This server script serves files from a subfolder called 'public'

  adapted from expressjs.com examples, 2016
  by Tom Igoe
*/
var express = require('express');	        // include the express library
var server = express();					          // create a server using express
server.use('/',express.static('public')); // serve static files from /public
server.listen(process.env.PORT || 8080);  // start the server
/*
  WiFi TCP Client
  TCP Socket client for WiFiNINA and WiFi101 libraries.
  Connects to the TCP socket server, reads a sensor once
  every five seconds, and sends a message with the reading.

  You'll need to include an arduino_secrets.h file with the following info:
  #define SECRET_SSID "ssid"      // your network name
  #define SECRET_PASS "password"  // your network password

  Here's a test with netcat: 
  char serverAddress[] = "x.x.x.x";  // replace with your computer's IP
  then on your computer, run  netcat:
  $ nc -klw 2 8080 | tee log.json
  This will send the output to the command line and to a file called log.json

  created 30 Dec 2022
  updated 27 Jan 2025
  by Tom Igoe
 */

// #include <WiFi101.h>   // use this for MKR1000 board
#include <WiFiNINA.h>  // use this for Nano 33 IoT or MKR1010 boards
// #include <WiFi.h>      // use this for Nano ESP32 board
#include "arduino_secrets.h"

// Initialize the Wifi client library
WiFiClient client;

// replace with your host computer's IP address
const char server[] = "192.168.1.96"; // 0.0.0.0
const int portNum = 8080;
// change this to a unique name for the device:
String deviceName = "first";
// message sending interval, in ms:
int interval = 5000;
// last time a message was sent, in ms:
long lastSend = 0;

void setup() {
  //Initialize serial
  Serial.begin(9600);
  // if serial monitor's not open, wait 3 seconds:
  if (!Serial) delay(3000);
 
  // Connect to WPA/WPA2 network.
  WiFi.begin(SECRET_SSID, SECRET_PASS);

  // attempt to connect to Wifi network:
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(SECRET_SSID);
    // wait a second for connection:
    delay(1000);
  }
  Serial.print("Connected to to SSID: ");
  Serial.println(SECRET_SSID);
  Serial.print("IP: ");
  Serial.println(WiFi.localIP());
  Serial.print("Signal Strength (dBm): ");
  Serial.println(WiFi.RSSI());
}

void loop() {
  // if the client's not connected, connect:
  if (!client.connected()) {
    Serial.println("connecting");
    Serial.println(server);
    Serial.println(portNum);
    client.connect(server, portNum);
    // skip the rest of the loop:
    return;
  }

  // once every interval, get a reading and send it:
  if (millis() - lastSend > interval) {
    // read sensor:
    int sensor = analogRead(A0);
    // format the message as JSON string:
    String message = "{\"device\": \"DEVICE\", \"sensor\": READING}";
    // replace READING with the reading:
    message.replace("READING", String(sensor));
    // and DEVICE with your device's name:
    message.replace("DEVICE", deviceName);
    // send the message:
    client.println(message);
    // update the timestamp:
    lastSend = millis();
  }

  // check if there is incoming data available to be received
  int messageSize = client.available();
  // if there's a string with length > 0:
  if (messageSize > 0) {
    Serial.println("Received a message:");
    Serial.println(client.readString());
  }
}