The second day has gone much better, I have blinked an onboard LED, an offboard LED, and written a 10 line http server using node.js.
The offboard LED provided some interesting insights. The BBB uses 3.3 volt logic, and I measured a logic high at 3.15 volts on one of the GPIO pins. This was pretty weak driving an LED through a 270 ohm resistor. The green LED I was using drops 2.05 volts (which is pretty typical) so the current would be 1.1/270 = 4 mA, which is pretty feeble.
It was easy to add a NPN transistor, drive the base directly from the BBB GPIO pin and connect the LED and resistor to the collector, the emitter to ground. The LED is now being driven by an external 5 volt supply. This gives a current of 3/270 = 11 mA. This is exactly how I anticipate interfacing a number of lines that will need to drive 5 volt logic (although some of those may also require pull up resistors.
Another important issue is the state of pins after reset (so systems do not come on enabled and so we can avoid glitches during the interval between power on and when our software takes control. The BBB sets the pins that I have investigated so far to zero states (I measure 0 volts). With my transistor (which is effectively an inverter), this means that my LED is not coming on, although if I was using this to drive a line with a pull up, the pull up would be bringing the line high -- I will have to use an inverter to follow up lines like this in critical situations.
npm install socket.ioAnd get an error: SSL Error: CERT_NOT_YET_VALID
The trick is that I have to set the time first:
ntpdate -b -s -u pool.ntp.org npm install socket.ioThis seems to work, and it is pulling in numerous other packages. However it places a directory node_modules at my current directory. I would rather have socket.io installed alongside the other node_modules, so we repeat the process as:
su cd /usr/lib npm install socket.io
node HtmlLedDemo.jsThis seems happy now and is running a server on port 8080. And it works!! (as near as I can tell). So I can study this demo in detail. This is good. Here are the files:
Tom's Computer Info / [email protected]