Other USB Interactive Device Coding

I have an interest in coding to interact with a USB device.

For example, reading a thermometer then picking a relay to start the whole house fan.

Is there a lead anybody might have as to how to start? Any platform, language agnostic, although am fluent in ASM, C and Delphi.
 
I'm not sure I understand what you're looking for, an Arduino board is programmed via USB and can communicate via USB through an TTL-USB converter. Right now I'm using a Waveshare USB to RS232-485-TTL.
 
Yeah, I would also recommend an RS232/TTL<->usb adapter.
Not strictly USB programming (i.e no libusb, etc needed); it just comes up as a serial port.

Then a simple atmega328p(u) (DIP package, convenient for breadboards)

(....or an Arduino (including nano clone) is basically is the equivalent to the above USB-TTL adapter and the atmega328p. Might be a little easier when starting out. Besides, you will need a hardware programmer anyway and weirdly, an Arduino is one of the better programmer options available, even with a fancy DIP expansion)

And finally, the compiler (devel/avr-gcc) and programmer (devel/avrdude). Note: even if you decide to use an Arduino, I wouldn't bother with the Arduino environment itself. Its all a bit messy and much of the effort is working out the terrible documentation and broken translation of the hardware anyway.

Then, once you can set pins high/low, drive i2c, PWM and read UART, you can start controlling various controller boards. For example this motor controller. This MOSFET controller may be useful for your specific task.

This book is really good. They use the ATmega168 but it is all very similar. Both were in various generations of Arduino.
 
Another (much, much heavier) option in a USB formfactor is the Nordic nRF52840. It involves compiling/working with the Zephyr RTOS (bare metal is tough) which currently isn't quite workable on FreeBSD (or the SEGGER programming tools).
 
Thanks for the pointers.
I have no idea where to pick up the end of the string to start following it.

I have a practical need for an appliance to monitor the outdoor temperature.
Once it drops below a given point, to pick a relay and start the whole house fan.
When the monitored temp goes above a determined point, it drops the relay and shuts off the house fan.

I'm thinking FBSD or similar, as an appliance than runs stable without needing a monitor or keyboard.
Remote into the appliance for control.
 
Thanks for the pointers.
I have no idea where to pick up the end of the string to start following it.

There is a lot to take in. Generally start with the best project of all, getting a flashing LED working via the Arduino/atmega as the 'Hello World' equivalent. Then, once you can do that, the next step could be to read from the pins for i.e the temperature sensor.

The mentioned book guides the process quite well.
 
Aye. Start with an Arduino UNO or Mega. Learn how to code their GPIO, there's a whole bunch of different "hats" you can get for it, temperature sensors, relays and a whole bunch more. Don't need to learn electronics as everything is already designed to 'snap' on top of an Arduino. There's also a tonne of example code to look through. Go to town, record temperature changes, print them to the Arduino's serial output. Add thresholds when the relay should activate/deactivate (add hysteresis, you'll figure out why soon enough).
 
Back
Top