USB HID ATmega32u4 Arduino - system device ID / name changing from default Arduino Leonardo - keyboard

I'm building a USB HID device using Arduino Leonardo mini clone, based on ATmega32u4. That particular IC has got a USB controller built in, and turning it in to a HID device is simple. You just need to include Keyboard.h and then use Keyboard.print...
Where can I set/define the name of the device that is shown, when that Arduino is connected to a PC, because at the moment it is named Arduino Leonardo.
The default automated name for tty is usbmodemHIDP1.
In system preferences, I can see:
ID product: 0x8036
ID vendor: 0x2341
Wersion: 1.00
Serial number: HIDPC
Speed: do 12 Mb/sek.
Vendor: Arduino LLC
ID location: 0x14200000 / 16
So where in Arduino is file Keyboard.h? Can I change that name, or ID's?
Is it possible?
Because in my opinion it should be, but I just can't find the right place, and I do not have experience with Arduino AVR as I was working with Microchips Mplab X before for different ICs ;).

The "iProduct" string sent by the board on enumeration tells the operating system to give it the human-readable name. The value of that string is set near the top of USBCore.cpp in hardware/arduino/cores/arduino/. It's a Unicode string, so we need looking for 'L', 'e', 'o', 'n' [...], not "Leonardo". The string used depends on the PID number of the device (also sent during enumeration) which is given in boards.txt.
For distributing own custom hardware based on the Leonardo, there is a need to provide your own VID.
Also there can be used alternative firmware.
The Arduino '32U4 bootloader, Caterina, can be found under hardware/arduino/bootloaders/caterina. It requires LUFA in order to build.

Related

yj-16009 iBeacon Proximity BLT beacon

I'm making a project with Esp32 whroom, so I bought the yj-16009 iBeacon DataSheet and I'm trying to get it to work as wireless Bluetooth proximity sensor like in this Video
I used the this code from the video and the esp32 is monitoring and showing BLT scanning results like this the results shown are after I turned off any BLT device around so first I don't understand what it is reading, and second after I turn on the iBeacon the results remain with the same range of numbers no matter if I get the iBeacon closer or farther, therefor I came to the conclusion that it doesn't recognize the iBeacon sensor for some reason.
I also download an app named LightBlue which does recognize the iBeacon sensor.
My question is if anyone knows how to make the esp32 recognize the iBeacon sensor. Another thing I tried to find any information about this sensor and there is no info about it anywhere. I have read on other questions here that it might need to be programmed somehow which I don't know how to do because there is no info online. So if anyone is familiar with this kind of sensor and can help me figure how to make the ibeacon to work like the video above as a Bluetooth Proximity device it would be a blessing.
The code you reference is just scanning for any BLE advertisements (iBeacon or otherwise) and printing out the RSSI signal strength of each detection. The reason you do not see the RSSI change when you move the beacon is because the ESP32 is probably picking up non-iBeacon adverts from your phone, laptop and other Bluetooth enabled devices in the vicinity which are not moving (there are more around you than you think!)
In order to make the device detect iBeacon only (and not all the other devices) you need to change the C code to do a few more things:
Access the bytes of the advertisement payload and use them as follows:
Compare the beginning of these bytes to see if they include the iBeacon byte sequence FF 4C 00 02 15
If the above byte sequence is not in the advertising data, ignore that detection — it is not an iBeacon advert
If it does include that byte sequence, decode the next 16 bytes as the iBeacon uuid, the next two bytes as the major and the next two bytes as the minor. See my answer here: What is the iBeacon Bluetooth Profile
Print out the identifiers along with the RSSI that the code already prints.

need to send ASCII codes over Bluetooth

Just looking for a "pre-made" device that could get ASCII codes (at the same time power up the device where the codes come from) and send the ASCII string over Bluetooth,
Technically, I want a device where I can connect standard Keyboard with a USB plug, and send the the keystrokes via bluetooth,
Just wondering if there is a device already setup to do this, no time to develop,
thanks
Assuming you want to convert a USB keyboard to Bluetooth, there's a handful of options out there, like the BT-500 from handheldci.com: http://handheldsci.com/kb/
And some similar FOSS arduino version: https://github.com/juancgarcia/HID-Relay
If this is not what you're trying to do, you'll need to specify it a bit better. "send characters over bluetooth" is sadly not that simple, the bluetooth device has to identify as some type of device. That could be a keyboard (HID), however it could also be something like a serial port over bluetooth which something like a HM-05 implements.

How does Linux determine a device class?

Linux newbie question.
Just wondering how Linux determines which device class a device is? Specifically, when I plug a barcode scanner in how does it know it is an ttyACM device? I have a scanner that works with my Linux OS but the new model isn't recognized so I'm wondering if I can alter a file somewhere in the system that tells it to recognize the scanner as ttyACM0 and use the existing drivers.
USB devices (I assume your scanner is USB) are identified by vendorId and productId (two 16bit integers), each driver fill an array with the list of supported vendor/prods id (creating a relation vendor:prod->driver), I guess at compile time all the id in the array are merged together in a list which then is used for a lookup search when a device is plugged in.
Usually you can see vendor and product id of the attached device with dmesg command right after the device is plugged in (or with lsusb).
For ttyACM see acm_ids[] in drivers/usb/class/cdc-acm.c
Careful playing around with device drivers, even being ttyACM a terminal interface only if the interface tty->hardware is implemented poorly some command may break the hardware.
Perhaps this question should be in Unix & Linux stackexchange

Read digital data directly from a USB port

I use Arduino for comunication between sensors and my C# application using a serial port. Is there any possibility to access digital components directly such as Force Sensitive Resistor - Square, from a USB port?
Do I have to write a driver for that?
I drew a semi-schematic diagram to exemplify:
There isn't a way to directly read an analog sensor over USB since it's a digital bus. You need some sort of processing to convert the analog signal to digital and communicate over the bus properly.
In order to sample information from any sensor, you will need an intermediary. The Arduino uses an FTDI chip to convert UART (Serial) to USB. When you read data over this connection, you are reading it over the Serial over USB interface. My recommendation is to stick with using the Arduino or other micro controller.
If you are really bent on reading it Directly over USB (instead of through the Serial over USB converter) you would have to implement some sort of protocol in a device that supports USB such as the Stellaris Launchpad or an Atmega32U4 AKA Arduino Lenardo. You would also have to write a driver to describe how to communicate with this USB device. Unless you were able to implement it as an already known device such as a keyboard or serial port (Yep, we went full circle there).
In short, there's no already made chip that converts Analog (or Digital) values from a sensor into something any OS would natively understand. Since USB is a protocol much like IP, you're not going to be able to use discreet devices. You're going to have to use a micro-controller with a USB stack.
Again, my advice would be to pass the sensor values over USB through the existing Serial (over USB) port. This is pretty straight forward and easily reproducible without an entire Arduino.
From the looks of the force-sensitive resistor, this is an analog component; the resistance and capacitance changes with the force applied to the sensor. If you check out the FSR installation guide document there are suggested electrical interfaces starting on page 16.
I would recommend the first circuit, connect Vout to an analog input on the Arduino. From there you will need to convert from ADC counts to voltages and then use a lookup table function in the Arduino to convert from voltage to force according to Figure 9. At this point you have a variable containing the force applied to the sensor. From here you can transmit the value over the USB serial bus just like any other value. Your C# application then needs to read the serial data, and parse out the value.

How would I control the output of the power in USB ports in Linux?

I built a robot from a thin client pc (can run Windows CE or Linux) and two servo motors. I put USB ends on the servo motors, so when they are plugged in to the thin client they continuously run. In Linux, how could I set the amount of current or voltage going from the USB ports to the servo motors? Would I be able to run a shell script to set the power of a certain USB port to slow down a motor or stop one? If this cannot be done through software, what is the easiest way to do this through hardware without having to buy too much?
The USB voltage is fixed at a nominal 5 volts and cannot be controlled.
The behavior of USB devices regarding their current draw is well defined in the USB specifications. USB devices are supposed to draw up to 1 unit load (100mA) unless they have negotiated a higher load from the USB host. It's quite likely that the servo motors that you have are going to need to draw higher currents than that, and wouldn't be able to request it without being a USB device and negotiating with the host.
It's also likely, depending on the servo motor that you are trying to control, that you'll need to either provide a PWM signal or an analogue voltage to control motor position. USB hosts are not intended to provide either of these.
Your best options to drive your motor from your PC are:
Get a dedicated USB controller for your servo motor (if one exists)
Make your own, based on a small microprocessor (eg. using an arduino)
Choose a different port on the PC. If available, PC parallel ports can be controlled to provide control for motor drivers.
The answers here seem to say it is a hardware issue, but I think this is a software issue. ASUS has Ai Charge which more then doubles the volts to charging Apple products from a standard 2.0 usb port.
USB 1.0, 2.0 and 3.0 Specs (All at 5 volts) 4 Wires (2 Data and 2
dedicated power)
Voltage Breakdown: USB 1.0 and USB 2.0 = 0.5A or 500 mA = 2.5 watt
USB 3.0 = 0.9A or 900mA = 4.5 watt Wall wart = 1.5A or 1500 mA = 7.5
watt Ai Charge = 1.2A or 1200mA = 6 watt
Ai Charge works on ASUS and non-ASUS motherboards and is a program you can install in Windows.
Personally I HATE Apple so I want to figure out a way to do this 1.2A usb 2.0 output trick for my netbook while running Linux.
I don't believe it is possible to directly manipulate the USB voltages. They are designed to provide a +5V output at all times unless power is diminised with other hubs.
You might be better served posting this question on http://electronics.stackexchange.com
you need to use PWM to control motors speed, to do that you need a micro controller, PIC18F series supports USB communication, there are plenty of code samples available internet how to use USB in PIC18F series, also you need a transistor array or H-Bridge to control mortors from PIC.
The simplest way to communicate is, program a USB serial in PIC18F micro controller, and when you plug that 18F to your computer, it will detect USB serial port, so you can send the commands to serial port to control speeds.
I dont think its possible, and even if it was, consider this: The USB port is not suposed to power motors because you can burn the USB port. USB is limited to 500mA (or there abouts) and any power device like a motor can potentially require more than that.
Another thing is that servos should be driven with constant voltage, and the speed is controlled by timing impulses on the control wire.
http://en.wikipedia.org/wiki/Pulse-width_modulation
You should use a driver (hardware) to power the motor with an external power source.
This is transistor's purpose, or try with a potentiometer

Resources