How to write data to a custom field
As far as the procedural method is concerned, you would use exactly the same method for a custom field as you would a contrib/core field.

Core field:

$node-&gt;body[LANGUAGE_NONE][0] = array(
  'value' = '&lt;p&gt;Some body text&lt;/p&gt;',
  'format' =&gt; 'full_html',
);


Your custom field:

$node-&gt;field_whatever[LANGUAGE_NONE][0] = array(
  'esn_hex' =&gt; $some_val,
  'esn_dec' =&gt; $some_other_val,
  // etc...
);


To persist changes to both, use node_save() (or entity_save(), or whataver helper method the entity you're using provides).

node_save($node);


That's all you need to do. Manipulating the field tables manually is not recommended, as you bypass a lot of hooks that need to run, cache management, etc.

To use custom fields with an EntityMetadataWrapper, you need to go a bit further and describe the field and its columns to the entity module.

This involves adding property_type and property_callbacks to your field definition in hook_field_info(), and providing appropriate callbacks for those. There's a bit more information in this post