Determine imp version

Is there a way to programmatically determine which version of the imp is being used? I’m currently using the imp001-April pair and I’d like to use the same code, but be able to introduce boards with the imp002-P3V3 pair and take advantage of additional GPIO ports. I haven’t thought through all the implications of this approach, but thought I’d ask just to learn if it’s possible.

I don’t know if this is technically reliable but I use hardware.getdeviceid() to determine individual pieces of hardware.

The imp002 modules I have are always starting with “2000” so one result would look like 20000c2####…

The results from imp001 modules have something other than “2000” in those 4 characters.

https://electricimp.com/docs/api/imp/environment/

Two choices straight from the docs:

`function checkEnvironment() {
if (imp.environment() == ENVIRONMENT_CARD) {
server.log(“This is an imp card”);
}
else if (imp.environment() == ENVIRONMENT_MODULE) {
server.log(“This is an imp module”);
}
}

function checkIfPinExists(pinName)
if (pinName in hardware) {
server.log(pinName + " exists!");
}
else {
server.log(pinName + " does not exist");
}
}

checkEnvironment();
checkIfPinExists(“pin1”);
checkIfPinExists(“pinA”);`

Thanks! Somehow I just couldn’t find that.

apparently neither could I. so embarrassed. literally my face turned red when I realized how cruddy my idea was compared to the professional, documented solution. anyway glad it got straightened out : )